LINUX
CP (COPY) COMMAND
$ cp [options] [source] [destination]
1. copy the content of the first file into the another file
$ cp file1.txt file2.txt
This command create a file file2.txt and copy the content of file1.txt into the file2.txt.
If file is already exist, it will only move the content of file.
2. copy the file into the directory
$ cp aman.txt software
This command copy the file aman.txt into the directory software.
3. copy the Multiple files into the single directory
$ cp aman.txt abhi.txt software
This command copy the file aman.txt and abhi.txt into the directory software.
4. over writing the copy file
$ cp aman.txt software
Suppose you copy a file into a directory which is already exit in that directory, which means over-write that file.
For doing this you want asking before over-write use the option -i with the cp command.
$ cp -i aman.txt software
Note : You can also use the absolute path.
5. copy the whole directory
$ cp -R software hardware
This command create a directory hardware (because it doesn't exit, if exist it will not created ) and copy the whole software directory into the hardware directory, use option -R with the cp command.
Your feedback is important for us :)

Post a Comment
0 Comments