Get Started With Ubuntu 18.10 by Vogel Matt

Get Started With Ubuntu 18.10 by Vogel Matt

Author:Vogel, Matt [Vogel, Matt]
Language: eng
Format: mobi
Published: 2018-12-20T16:00:00+00:00


12.8.1.2 Copy a file to a different directory

The cp command can also be used to copy a file to different directory.

In the example below the cp command is used to copy myfile1 to the /tmp directory. The cd command is used to change to the /tmp directory and the ls command is used to verify the file copy.

When using the cp command to copy a file to a different directory you can omit the filename in the new location and the new file will have the same name as the original. You can also give the new file a new name when copying it to a different directory.

12.8.1.3 Copy a file from one directory to another

You can copy a file from one directory to another without being located in either directory by using paths, either relative or absolute.

In the example below the cp command is used to copy /tmp/myfile1 to the myfolder directory in the home folder, ~/ , and name the new file myfile3. The ls command is used to list the contents of myfolder without changing to the myfolder directory. In this example the working directory was neither the copy from nor the copy to location so relative and absolute paths had to be used with the cp command.

Absolute paths always start with the / character indicating the root directory and specify the absolute location in the file system. The ~ character in the prompt means the current location is the user’s home directory.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.