Cp afile afilebak Copies the file afile to a new file afilebak

■ cp afile /home/bible/: Copies the file afile from the current directory to the directory / home/bible/.

■ cp * /tmp: Copies all nonhidden files in the current directory to /tmp/.

■ cp -a docs docs.bak: Recursively copies the directory docs beneath the current directory to a new directory docs.bak, while preserving file attributes and copying all files including hidden files whose names start with a dot. (-a stands for archive, so this command is making an exact "archive" copy of the directory docs as docs.bak, recursively copying all files and directories within it.)

■ cp - i: By default, if you copy a file to a location where a file of the same name already exists, the old file will be silently overwritten. The -i option makes the command interactive; in other words, it asks before overwriting.

■ cp - v: With the -v (verbose) option, the cp command will tell you what it is doing. A great many Linux commands have a -v option with the same meaning.

Was this article helpful?

0 0

Post a comment