![]() Here's what you can do: Copy only the contents of a directory (not the directory) So, what do you do when you only want to copy the directory's contents, not the directory itself? You'll have to use the same cp command but with the recursive option -r to copy a directory with all its content to another location: cp -r Source_dir Target_dirįor example, here, I have copied a directory named IF to LHB: But there is no cpdir command for copying directories. There is mkdir command to make new directories, rmdir to remove (empty) directories. You already know about creating files and folders so recreate everything. Practice all the above-discussed examples yourself. Here, I copy multiple files to a new location. To copy multiple files to another directory, execute the command in the following fashion: cp File1 File2 File3 FileN Target_directory This way, you can revert to the old configuration if things don't go as planned. A good practice is to make a backup of the config file in the same location before editing it. Why would you do that? Say, you have to edit a config file. ![]() cp Source_file Renamed_fileįor reference, here, I have copied a file named Hello.txt to the same directory by renaming it to Renamed_Hello.txt: Just give a different name to the 'target file'. You can choose to rename the file while copying it. To copy one file to another directory, all you have to do is follow the given command syntax: cp Source_file Destination_directoryįor example, here, I have copied a file named Hello.txt to the directory named Tux:Īnd as you can see, the file has successfully been copied to the Tux directory. ![]() Let me show you a few examples of copying files. Let's go on with the seventh chapter in the series. Just to recall, here's what you have learned so far in this Terminal Basics series: ![]()
0 Comments
Leave a Reply. |