Link to home
Start Free TrialLog in
Avatar of Alaska Cowboy
Alaska CowboyFlag for United States of America

asked on

UNIX command question, what is xargs doing ?

trying to figure out what this is doing . . .

ls | xargs file | grep -v "directory" | cut -d: -f1 | xargs -i mv -f {} oldfiles

I can tell it copies everything, but don't understand "xargs"

I know "ls", "grep -v", "mv"

"oldfiles" is a directory.

i'd like to move everything EXCEPT
- *.dat
- trigger_file_name.txt
SOLUTION
Avatar of ThomasMcA2
ThomasMcA2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alaska Cowboy

ASKER

Thomas, thanks for the instruction, I will give it a try.

gerwinjansen, thanks as well, I will try that too.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ozo, ok will do that too, thanks.
sorry I didn't post back yesterday.

Everything worked great ! just as you explained. I understand it now and have tested it out successfully.

Thanks !
No problem at all, thanks for your feedback!
follow-up, if you don't mind . . .

I wanted to filter files with a wildcard, so I tried this: grep -v \edw*prd*.dat, but the system went haywire, like an infinite loop . . .

ls | xargs file | grep -v "directory" | grep -v \edw*prd*.dat | grep -v ftpGood | cut -d: -f1 | xargs -i mv -f {} ol
dfiles

Open in new window

How can I do this wildcard ?
what is \e ?
did you mean
grep -v 'edw.*prd.*\.dat'
yes, I think that IS what I mean . . . syntax obviously a mess . . . but what is the slash for ?
in a grep regular expression, \. matches a literal [.] instead of any character
Outside of quotes in a shell command line, \e is just e
Ok, I'll try that, thanks !