I am trying to extract many rar files at once, but with no successful. I am trying in the order:

>ls *.rar|xargs unrar x
>ls *.rar|xargs unrar e
>unrar e -r *.rar
>for f in *.rar;do unrar e “$f”;done

no ones works. Rar answers every times saying that there are not file to exctract.

>Extracting from damned_file.rar

 No files to extract

If I try to extract the file one by one, then all works fine

>unrar e damned_file.rar
 extracting damned_file.rar                        
 extracting dmaned_file.txt                            OK
 All OK

My version of rar is

UNRAR 4.10 freeware      Copyright (c) 1993-2012 Alexander Roshal

What I am doing wrong?

PS: The command

find . -name "*.rar" -exec unrar e {} \;

works fine, but the question remain the same. Why the previous commands fails?


Here is my go-to for loop:

for file in *.rar; do unrar e "$file"; done

xargs puts arguments behind the command provided to it up until the maximum command length for your current shell, so the command would be:

xargs unrar e damned_file.rar another_damned_file.rar yadf.rar

However, unrar only takes a single rar file as argument. The find command you specified runs unrar for every single file it finds, so the command is unrar e damned_file.rar, unrar e another_damned_file.rar.

  • 1
    so why for loop won't work?
    – emanuele
    Apr 10 '14 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.