문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

Why not a regular loop?

while read -r file1 file2 ; do
  cp -- "$file1" "$file2";
done < file
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top