Skip to content
Advertisement

“xargs -a file” to copy files to a folder

I am tring to use xargs -a to read the contents of a file that has a list of filenames in it.

My directory working in looks like:

JavaScript

File name with filenames in it: bakfiles.txt

bakfiles.txt contents:

JavaScript

So essentially I’m trying to copy file1.bak,file2.bak,file3.bak into the folder backups. But using the contents of bakfiles.txt to do so.

I tried:

JavaScript

But I get the error:

JavaScript

I should mention i also tried:

JavaScript

And get the error:

JavaScript

Advertisement

Answer

From the following link i figured it out:

https://superuser.com/questions/180251/copy-list-of-files

Heres the command:

xargs -a bakfiles.txt cp -t backups

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement