Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was wondering if anyone is able to help with my query. I am trying to unzip every .zip file in a certain directory. I am using the # unzip command and at present I am unzipping each file singularly.
I have searched the man pages on 'unzip' but cannot find any directions/options outlining if it is possible to globally unzip all .zip files in a directory in one command.
If anyone has any suggestions, comments it would be greatly appreciated.
Initially, I tried the unzip command with that syntax and received the following error for each respective zip file: "caution: filename not matched: <file>.zip"
It does seem strange that global pattern matching does not work with the unzip command (or perhaps it does and I don't know about it?).
the -1 (number one) would ensure that it only fed one filename at a time without any permissions in case of an alias to ls that did not feed just the filenames to unzip.
i also added the grep to ensure that only files ending in .zip would be read
your solution works under ideal conditions which rarely exist for me
I know this topic is a bit old, but I'm running into the same issues, but I can't get the solution here to work either.
First, I'm getting exactly the same thing trying 'unzip *.zip'. I have about 30 files, and I get the "caution: filename not matched: <filename>.zip" error message.
So, I being that there are other files that are not .zip, I tried mhallbiai's solution and ran this:
for i in `ls -1 | grep .zip$`; do unzip $i; done
which, in turn, gave me this:
unzip: cannot find or open ls, ls.zip or ls.ZIP
I tried doing them one at a time and putting it in a simple shell script, but no luck.
So, I figure I'm missing something here, and hoping for an easy explanation.
BTW, this system does not have a GUI installed, so this has to be done through the CLI. Really hoping I don't have to sit there and manually unzip almost 30 zip files that are all almost 700MB!
Make sure the quotes you're typing in are "backquotes" (on my keyboard, it's on the upper left corner underneath "Esc"). Backquotes tell the shell to execute the contents, rather than just quoting the contents.
I personally find it an outrageously ugly syntax "feature".
Also, I'd put double quotes around $i, like so:
unzip "$i"
That's needed to work if some of the zip files have spaces.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.