To make a copy of a file in the current directory, enter:
$ cp file.doc file.doc.bak
To copy a file in your current directory into another directory, enter:
$ cp filename /tmp
$ ls /tmp/filename
$ cd /tmp
$ ls
$ rm filename
To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter:
$ cp -p filename /path/to/new/location/myfile
To copy all the files in a directory to a new directory, enter:
$ cp * /home/tom/backup
To copy a directory, including all its files and subdirectories, to another directory, enter (copy directories recursively):
$ cp -R * /home/tom/backup
No comments:
Post a Comment