1822010 Members
3948 Online
109639 Solutions
New Discussion юеВ

xargs cp

 
SOLVED
Go to solution
Inter_1
Frequent Advisor

xargs cp

Hi,

I want to cp a set of files.
I issue the command like this:
ls -ltr /apps/logs/ | grep -i stdout.log | xrags cp /apps/logs/{} /home/z15/logs/

I want to copy only the set of files that is as output of this command:
ls -ltr /apps/logs/ | grep -i stdout.log

Thanks
Andy
I like to fix things.
4 REPLIES 4
Sandman!
Honored Contributor

Re: xargs cp

ls -ltr /apps/log | grep -il stdout.log | xargs -i -n1 cp /apps/log/{} /home/z15/logs/
James R. Ferguson
Acclaimed Contributor
Solution

Re: xargs cp

Hi Andy:

Why use 'ls'?

How about:

# find /apps/logs -type f -name stdout.log | xargs -i cp {} /home/z15logs

Regards!

...JRF...
Sandman!
Honored Contributor

Re: xargs cp

Use the pipeline below instead of the one in my last post:

# ls -1 /apps/logs | xargs grep -il stdout.log | xargs -i cp {} /home/z15/logs/

~cheers
Inter_1
Frequent Advisor

Re: xargs cp

Thank you all.
I like to fix things.