Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use cp from stdin?

Tags:

stdin

cp

cygwin

Note:

# cat /tmp/foo - regular file

/lib/a.lib
/lib/b.lib
/lib/c.lib
/lib/d.lib

cat /tmp/foo | xargs cp /tmp/fred

cp: target /lib/d.lib is not a directory

like image 451
Aaron Avatar asked Dec 01 '22 11:12

Aaron


1 Answers

xargs normally places its substituted args last. You could just do:

$ cp `cat /tmp/foo` /tmp/fred/.

If it's really just the lib files, then cp /lib/?.lib /tmp/fred/. would naturally work.

And to really do it with xargs, here is an example of putting the arg first:

0:~$ (echo word1; echo word2) | xargs -I here echo here how now
word1 how now
word2 how now
0:~$ 
like image 61
DigitalRoss Avatar answered Dec 06 '22 08:12

DigitalRoss