Linux Command Line (10) Copy Files and Directories

preview_player
Показать описание
The copy command works similar to the move command, the word copy is shortened down to 2 letters cp and then we type in the source and the destination

To copy to the same directory you would type cp the filename then the copy-filename

We can add options -f for force (overwrite if file exists), -n for no-clobber (Do not overwrite file if it exits), -v for verbose, and -i for interactive (Ask before overwriting the file) to the copy command

We add some files to the Newdirectory2 directory with the command:
Touch Newdirectory/Newdirectory2/file{a,b,c}.txt

When copying a directory, we must use the -r option to recursively copy everything in that directory
cp -r Newdirectory/Newdirectory2/ .

If you use the -i for interactive when copying a directory, it will ask to confirm copy file for every file in that directory (control+c with cancel you out of that)

Using the -u option will only copy files that have been updated

Website link:
Рекомендации по теме
Комментарии
Автор

I have watched a lot of Linux tutorials and yours are by far the easiest to understand and to learn from. THANK YOU!

glendubie
Автор

can you help me with the file name, , I am trying to generate folders on a domain from a csv and unzip the file.zip. the file below is named t1.sh.. the file where the names for folders are in files/folder2.csv . I have an ambiguous error line 16 which is the done< $filename

mickmc