Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a bunch of zip files I want to unzip in Linux into their own directory. For example:

a1.zip a2.zip b1.zip b2.zip

would be unzipped into:

a1 a2 b1 b2

respectively. Is there any easy way to do this?

share|improve this question

2 Answers 2

no need to use external basename

for file in *zip
do
 unzip -d "${file%.zip}" "$file"
done
share|improve this answer

for x in *.zip; do unzip -d "$(basename "$x" .zip)" "$x"; done

share|improve this answer
    
Or, with ghostdog74's advice: for x in *.zip; do unzip -d "${x%.zip}" "$x"; done –  janmoesen Mar 17 '10 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.