Please don't call your file file
!
cat list | xargs -n 2 cp
Here the switch -n 2
is crucial: it tells xargs
to use at most 2
arguments per line.
Pregunta
My file includes:
a.txt b.txt
c.txt d.txt
e.txt f.txt
Want to do cp a.txt b.txt
, cp c.txt d.txt
, cp e.txt f.txt
What is the quick oneliner to do this ?
I try cat file | xargs -I{} cp {}
. but it does not work since it treats the whole thing as one argument.
Solución
Please don't call your file file
!
cat list | xargs -n 2 cp
Here the switch -n 2
is crucial: it tells xargs
to use at most 2
arguments per line.
Otros consejos
Why not a regular loop?
while read -r file1 file2 ; do
cp -- "$file1" "$file2";
done < file