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
cp errorfile.txt Newdirectory
To copy to the same directory you would type cp the filename then the copy-filename
cp errorfile.txt errorfile-copy.txt
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
cp -vi errorfile.txt Newdirectory
We add some files to the Newdirectory2 directory with the command:
Touch Newdirectory/Newdirectory2/file{a,b,c}.txt
This will create three files filea.txt, fileb.txt, and filec.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
Nguồn: https://codeigniterbrasil.com
Xem thêm bài viết khác: https://codeigniterbrasil.com/lap-trinh-linux/
Xem thêm Bài Viết:
- Hướng dẫn sử dụng hệ điều hành linux siêu tốc – bài 25 Xem cấu hình hệ thống (cpu, ram, hdd)
- Linux cat command summary with examples
- Cài nhiều hệ điều hành Windows và Linux trên một máy tính
- Hướng dẫn tạo USB Boot DLC2019 (NTFS / UEFI) Trên windows 10 ( sử dụng USB 32 GB )
- Hướng dẫn gỡ bỏ Ubuntu sạch sẽ nhất bằng lệnh trên Windows theo chuẩn UEFI-GPT