Avatar of Alaska Cowboy
Alaska Cowboy
Flag 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
Unix OS

Avatar of undefined
Last Comment
Alaska Cowboy

8/22/2022 - Mon
SOLUTION
ThomasMcA2

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Gerwin Jansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Alaska Cowboy

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

gerwinjansen, thanks as well, I will try that too.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Alaska Cowboy

ASKER
ozo, ok will do that too, thanks.
Alaska Cowboy

ASKER
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 !
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Gerwin Jansen

No problem at all, thanks for your feedback!
Alaska Cowboy

ASKER
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 ?
ozo

what is \e ?
did you mean
grep -v 'edw.*prd.*\.dat'
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Alaska Cowboy

ASKER
yes, I think that IS what I mean . . . syntax obviously a mess . . . but what is the slash for ?
ozo

in a grep regular expression, \. matches a literal [.] instead of any character
Outside of quotes in a shell command line, \e is just e
Alaska Cowboy

ASKER
Ok, I'll try that, thanks !
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy