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?
It depends on how many files you have. Try a cp command and if you get the argument list too long error you'll need to use a different approach -- shell script, rsync.
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/
3 comments
[ 3.5 ms ] story [ 16.1 ms ] threadhttps://askubuntu.com/questions/217764/argument-list-too-lon...
`$ tar -C $source-dir -c . | tar -C $dest-dir -x`