I have multiple files in a Linux systems where I want to copy them with a single cp command into a different path and directory. Should I write a bash script to copy one by one?
Printable View
I have multiple files in a Linux systems where I want to copy them with a single cp command into a different path and directory. Should I write a bash script to copy one by one?
cp -a /source/. /dest/
The -a option preserves all file attributes as well as symlinks. And the . at end of the source path is like a wild card telling cp you want to copy all files and folders, included hidden ones.
No. You shouldn’t write a bash script. Just use the cp command bulk copy feature and provide all files you want to copy and add the path which is the destination.
cp file1 file2 file3 /mnt/backup
Referece: https://www.poftut.com/linux-cp-or-copy-command/