TOPIC: SCRIPT
Unzipping more than one file at a time in Linux and macOS
10th September 2024To me, it sounded like a task for shell scripting, but I wanted to extract three zip archives in one go. They had come from Google Drive and contained different splits of the files that I needed, raw images from a camera. However, I found a more succinct method than the line of code that you see below (it is intended for the BASH shell):
for z in *.zip; do; unzip "$z"; done
That loops through each file that matches a glob string. All I needed was something like this:
unzip '*.zip'
Without embarking on a search, I got close but have not quoted the search string. Without the quoting, it was not working for me. To be sure that I was extracting more than I needed, I made the wildcard string more specific for my case.
Once the extraction was complete, I moved the files into a Lightroom Classic repository for working on them later. All this happened on an iMac, but the extraction itself should work on any UNIX-based operating system, so long as the shell supports it.
Using Korn shell commands in scripts running under the bash shell
19th May 2007This is actually a fairly simple one: just prefix the relevant command with ksh
like below (in the example below, bash
won't know what to do with the print command otherwise):
ksh print "Hello, world!"
It's also useful for running Korn shell scripts under the bash shell as well.