cp file in linux.
Copy file dùng cp command.
cp file_1 file_2
Nếu file_2 chưa có thì sẽ tạo ra, nếu đã có thì ghi đè.
[dt]% cd test
[dt-arco:test]
[dt]% ls
abc install_arco.txt
abc.txt output.txt
app.js remote_ubuntu
filter.txt t
index.html text2.txt
index.php text.txt
[dt-arco:test]
[dt]% cp abc.txt x.txt <-- copy file abc.txt ra x.txt
[dt-arco:test]
[dt]% ls
abc output.txt
abc.txt remote_ubuntu
app.js t
filter.txt text2.txt
index.html text.txt
index.php x.txt <-- copy thành công
install_arco.txt
[dt-arco:test]
[dt]%
Ta có thể dùng:
cp -i -v file1 file2
- -i : hỏi trước khi thực hiện
- -v : in ra cho ta xem.
Nếu copy nhiều file ta không dùng cp mà dùng cat.
cat f1.txt f2.txt > out.txt
Như vậy là ta đã copy đươc file trong linux rồi.