The cp and mv Utilities
Explore how to use the cp and mv utilities to copy, move, and rename files and directories within Bash. Understand the syntax, options for recursive copying, and how to handle existing files with overwrite controls. This lesson helps you manage file system objects efficiently in the command line environment.
We'll cover the following...
cp and mv
The cp and mv utilities copy and move file system objects. Their interfaces are almost the same. We specify the target file or directory in the first parameter, and pass the new path for the object in the second parameter.
Below is an example. We want to copy the report.txt file. First, we should go to its directory. Second, call the cp utility like this:
cp report.txt report-2019.txt
Run the commands discussed in this lesson in the terminal below.
This command creates the new file report-2019.txt in the current directory. Both report-2019.txt and report.txt files have the same content.
Let’s suppose that we don’t need ...