LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2004, 12:52 PM   #1
reitzell
LQ Newbie
 
Registered: May 2004
Posts: 17

Rep: Reputation: 0
xargs question


I'm doing something wrong with xargs. I had a bunch of rar files in a dir. and I can type unrar x file.rar and rebuild the archive. So, I thought I could ls *.rar|xargs unrar x and this would do the same thing but for all of the *.rar files I have but it doesn't work. Do you know what I'm doing wrong here?

Thanks,
Rob
 
Old 06-04-2004, 01:29 PM   #2
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
yea, the problem is that rar/unrar doesn't take multiple input files as its arguments, so basically
Code:
ls *.rar|xargs unrar x
is equivalent to
Code:
unrar x *.rar
which won't work.
You can setup a simple loop to do it one by one, eg:
Code:
for foo in *.rar; do unrar x $foo; done

Last edited by Demonbane; 06-04-2004 at 01:39 PM.
 
Old 06-04-2004, 01:29 PM   #3
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
How about:

find . -name *.rar -print0 | xargs -0 unrar
 
Old 06-04-2004, 03:50 PM   #4
reitzell
LQ Newbie
 
Registered: May 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks! Demonbane and micxz. This place rules!

(the "find ..." one doesn't work) but the for foo one does.
 
Old 07-04-2004, 03:36 AM   #5
45t3r15k
LQ Newbie
 
Registered: Jul 2004
Location: Illinois
Distribution: Debian
Posts: 5

Rep: Reputation: 0
Xargs rocks

try this
ls *.rar | xargs -i unrar x {}
Haven't tried it with the unrar command but I use this
ls *.wav | xargs -i lame {} {}.mp3
to encode a directory full of freshly ripped tracks to mp3 format
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xargs: unmatched single quote akudewan Linux - Newbie 5 07-28-2014 01:16 PM
xargs and my own script harmster Linux - Software 4 05-07-2005 11:35 AM
error with find . | xargs cbonar Linux - Newbie 7 12-09-2004 12:22 PM
What's difference btw. -exec and xargs rytrom Linux - Newbie 3 09-14-2004 04:42 PM
xargs: unmatched single quote fillatre Linux - Software 2 06-05-2004 11:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration