News for hackers. Stuff that matters.

Copy Bulk Files in Linux

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?
( 3 comments | on HN )
Re:Copy Bulk Files in Linux by edizgeorgi on Wednesday May 06, 2020 @09:02AM (#23090412)
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/
Re:Copy Bulk Files in Linux by DLA on Monday May 04, 2020 @11:47AM (#23069398)
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.

https://askubuntu.com/questions/217764/argument-list-too-lon...

Re:Copy Bulk Files in Linux by databasher on Wednesday May 06, 2020 @10:56AM (#23091660)
My go-to would be tar:

`$ tar -C $source-dir -c . | tar -C $dest-dir -x`