COPY (CP) COMMAND:
- THIS IS USED TO COPY ANY FILE.
- To overwrite the one file over another file
Command:
cp
Operation:
cp m.txt n.txt
Before:
cat > m.txt
Hi this is Gurudatt shet from sirsi,
cureently working in prwatech.
cat > n.txt
this is empty text file
Output:
cat > n.txt
Hi this is Gurudatt shet from sirsi,
cureently working in prwatech.
- To copy one directory content to another directory
Operation:
cp -r lin banglore
Before:
cd lin
a.txt b.txt c.txt Desktop Guru l m.txt n.txt p.txt r r.txt
cd banglore
“empty”
Output:
cd banglore
a.txt b.txt c.txt Desktop Guru l m.txt n.txt p.txt r r.txt
- To ask permission before overwriting the file
Operation:
cp -r new.txt prwa.txt
Type yes, for giving permission
No, for not to overwriting
Before:
cat new,txt
This is the training institution.
which is located in banglore and pune.
we mainly focused on Datascience , BigData and Google cloud.
thank you
If “yes”
Output:
This is the training institution.
which is located in banglore and pune.
we mainly focused on Datascience , BigData and Google cloud.
thank you
- if you want replace but want to keep your backup file
Operation:
cp -r new.txt prwa.txt
Always, (new.txt) is source
(prwa.txt) is destination
Before:
100.txt backup.txt corona.txt dumy lin new.txt poi prwa.txt
banglore delhi layout m.txt n.txt prwatech
cat backup.txt
Hello everyone
how are you all?
cat 100.txt
hope everyone are fine
Output:
100.txt backup.txt corona.txt dumy lin new.txt poi prwa.txt
100.txt~ banglore delhi layout m.txt n.txt prwatech
cat backup.txt
Hello everyone
how are you all?
cat 100.txt
Hello everyone
how are you all?
cat 100.txt~
hope everyone are fine
- if you want to overwrite without any modification time
Operation:
cp -i backup.txt siri.txt
Before:
cat backup.txt
Hello everyone
how are you all?
cat siri.txt
there is new update in your os
total 64
drwxr-xr-x 2 user user 4096 Dec 27 01:46 poi
drwxr-xr-x 3 user user 4096 Dec 29 01:46 dumy
-rw-r--r-- 1 user user 892 Dec 29 02:18 corona.txt
drwxr-xr-x 2 user user 4096 Dec 30 01:28 layout
-rw-r--r-- 1 user user 146 Dec 30 03:59 new.txt
drwxr-xr-x 2 user user 4096 Dec 30 06:22 delhi
drwxr-xr-x 6 user user 4096 Dec 30 07:30 prwatech
-rw-r--r-- 1 user user 69 Jan 2 13:10 m.txt
-rw-r--r-- 1 user user 69 Jan 2 13:14 n.txt
drwxr-xr-x 5 user user 4096 Jan 2 13:18 lin
drwxr-xr-x 3 user user 4096 Jan 2 13:19 banglore
-rw-r--r-- 1 user user 146 Jan 2 13:27 prwa.txt
-rw-r--r-- 1 user user 33 Jan 2 13:35 backup.txt
-rw-r--r-- 1 user user 23 Jan 2 13:36 100.txt~
-rw-r--r-- 1 user user 33 Jan 2 13:36 100.txt
-rw-r--r-- 1 user user 31 Jan 2 13:46 siri.txt
Output:
cat siri.txt
Hello everyone
how are you all?
total 64
drwxr-xr-x 2 user user 4096 Dec 27 01:46 poi
drwxr-xr-x 3 user user 4096 Dec 29 01:46 dumy
-rw-r--r-- 1 user user 892 Dec 29 02:18 corona.txt
drwxr-xr-x 2 user user 4096 Dec 30 01:28 layout
-rw-r--r-- 1 user user 146 Dec 30 03:59 new.txt
drwxr-xr-x 2 user user 4096 Dec 30 06:22 delhi
drwxr-xr-x 6 user user 4096 Dec 30 07:30 prwatech
-rw-r--r-- 1 user user 69 Jan 2 13:10 m.txt
-rw-r--r-- 1 user user 69 Jan 2 13:14 n.txt
drwxr-xr-x 5 user user 4096 Jan 2 13:18 lin
drwxr-xr-x 3 user user 4096 Jan 2 13:19 banglore
-rw-r--r-- 1 user user 146 Jan 2 13:27 prwa.txt
-rw-r--r-- 1 user user 33 Jan 2 13:35 siri.txt
-rw-r--r-- 1 user user 33 Jan 2 13:35 backup.txt
-rw-r--r-- 1 user user 23 Jan 2 13:36 100.txt~
-rw-r--r-- 1 user user 33 Jan 2 13:36 100.txt
MOVE COMMAND:
- IT IS USED TO MOVE THE FILE OR DIRECTORY
- To move the one file to another
Command:
mv
Operation:
mv prwa.txt lin
Before:
a.txt b.txt c.txt Desktop Guru l m.txt n.txt p.txt r r.txt
Output:
a.txt b.txt c.txt Desktop Guru l m.txt n.txt prwa.txt p.txt r r.txt
- To rename file without changing modification time.
Operation:
mv a.txt bravo.txt
Before:
total 44
-rw-r--r-- 1 user user 147 Dec 28 03:47 c.txt
drwxr-xr-x 5 user user 4096 Dec 28 04:23 r
-rw-r--r-- 1 user user 0 Dec 28 04:44 l
-rw-r--r-- 1 user user 22 Dec 28 06:03 m.txt
-rw-r--r-- 1 user user 47 Dec 28 23:52 n.txt
-rw-r--r-- 1 user user 8 Dec 28 23:58 b.txt
-rw-r--r-- 1 user user 8 Dec 29 01:06 a.txt
-rw-r--r-- 1 user user 2 Dec 29 01:36 p.txt
-rw-r--r-- 1 user user 2 Dec 29 01:36 r.txt
drwxr-xr-x 3 user user 4096 Dec 31 01:55 Guru
drwxr-xr-x 7 user user 4096 Dec 31 04:34 Desktop
-rw-r--r-- 1 user user 146 Jan 2 13:27 prwa.txt
Output:
total 44
-rw-r--r-- 1 user user 147 Dec 28 03:47 c.txt
drwxr-xr-x 5 user user 4096 Dec 28 04:23 r
-rw-r--r-- 1 user user 0 Dec 28 04:44 l
-rw-r--r-- 1 user user 22 Dec 28 06:03 m.txt
-rw-r--r-- 1 user user 47 Dec 28 23:52 n.txt
-rw-r--r-- 1 user user 8 Dec 28 23:58 b.txt
-rw-r--r-- 1 user user 8 Dec 29 01:06 bravo.txt
-rw-r--r-- 1 user user 2 Dec 29 01:36 p.txt
-rw-r--r-- 1 user user 2 Dec 29 01:36 r.txt
drwxr-xr-x 3 user user 4096 Dec 31 01:55 Guru
drwxr-xr-x 7 user user 4096 Dec 31 04:34 Desktop
-rw-r--r-- 1 user user 146 Jan 2 13:27 prwa.txt
- To move file keeping a backup(b) of it
Operation:
mv a.txt bravo.txt
Before:
total 4
drwxr-xr-x 2 user user 4096 Dec 31 01:55 x
Output:
total 8
-rw-r--r-- 1 user user 8 Dec 29 01:06 bravo.txt
drwxr-xr-x 2 user user 4096 Dec 31 01:55 x
- Ask a permission before replacing or renaming the file
Operation:
mv –i new.txt n.txt
Type yes, for giving permission
No, for not to move
Before:
b.txt c.txt Desktop Guru l m.txt prwa.txt p.txt r r.txt
if yes
Output:
b.txt c.txt Desktop Guru l m.txt n.txt prwa.txt p.txt r r.txt
- Forcefully moving the the file
Operation:
mv –f a.txt bravo.txt
Before:
b.txt c.txt Desktop Guru l m.txt n.txt prwa.txt p.txt r r.txt
Output:
b.txt c.txt Desktop Guru l m.txt new.txt n.txt prwa.txt p.txt r r.txt
- To move one directory to another
Operation:
mv delhi lin
Before:
user@ubuntu:~/Desktop$ ls
100.txt backup.txt corona.txt dumy lin poi siri.txt
100.txt~ banglore delhi layout m.txt prwatech
Output:
user@ubuntu:~/Desktop/lin$ ls
b.txt delhi Guru m.txt n.txt p.txt r.txt
c.txt Desktop l new.txt prwa.txt r
- to explain what has been done
Operation:
mv -v layout lin
Before:
user@ubuntu:~/Desktop$ ls
100.txt backup.txt corona.txt layout m.txt prwatech
100.txt~ banglore dumy lin poi siri.txt
Output:
renamed 'layout' -> 'lin/layout'
user@ubuntu:~/Desktop/lin$ ls
b.txt delhi Guru layout new.txt prwa.txt r
c.txt Desktop l m.txt n.txt p.txt r.txt
HEAD COMMAND:
- TO DISPLAY THE FIRST PART OF THE FILE
- To display the first 10 lines of the file.
Operation:
head corona.txt
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
the pandemic has not only affected the health of the people worldwide.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
Output:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
- to display first nth lines in the file
Operation:
head –n corona.txt
where n is number of rows you want.
Operation:
head –5 corona.txt
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
the pandemic has not only affected the health of the people worldwide.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
Output:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
- to extract middle some lines from the file
Operation:
head -5 corona.txt|tail -2
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
Output:
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
TAIL COMMAND:
- TO DISPLAY THE LAST PART OF THE FILE
- To display the last 10 lines of the file.
Operation:
tail corona.txt
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
the pandemic has not only affected the health of the people worldwide.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
Output:
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
teh pandemic has not only affected the health of the people worldwide.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
- To display last nth lines in the file
Operation:
tail –n corona.txt
where n is number of rows you want.
Operation:
tail –5 corona.txt
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
the pandemic has not only affected the health of the people worldwide but it has also caused Economic slowdowns across the globe.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
Output:
the pandemic has not only affected the health of the people worldwide.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
- To extract middle some lines from the file
Operation:
tail -3 corona.txt|head -2
Before:
corona Virus had caused by the deadliest pandemic of the century,
It is caused by the viru named COVID-19.
It mostly spreads from the dropliets of cough from the infected person.
the symptoms are fever, dry caughing, sore throat etc.
still there is not vaccine invented for the virus.
some of the precautionary measure would be social distancing , using mask etc
it was first detected in Wuhan , china.
WHO had annoced it as pandemic by the end of december 2020 itelf.
The virus had undergone too much of mutation.
so even if the vaccine is made for the virus, it may not work worldwide due to different straof the virus in different places.
the pandemic has not only affected the health of the people worldwide but it has also caused Economic slowdowns across the globe.
We are truely gratefull all medical and civil professionals
who are doing best to save us
from the disease
the end.
Output:
who are doing best to save us
from the disease.