To copy a file into another directory, use the
cp command with the file name as the first argument, and the target path name as the second.
$ cp fileName destination
You may rename the file by attaching it to the end of the path.
$ cp fileName destination/newFileName
This takes a file, and sends a copy of it to the specified path, with the new file name.
And to copy into the same directory with a new name:
$ cp fileName newFileName
To copy directories and the contents within, we must apply the
-r option, which is the command to copy recursively.
The following command would copy all contents of dir1 into dir2.
$ cp -r dir1 dir2
We can copy multiple items at once into a directory. As long as the last argument is the path name, we're good.
$ cp file1 file2 file3 pathName
Here are some additional options for fine-tuning.
Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.$ Check price
Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.$ Check price