[Techtalk] real life kewl text-processing and regexps samples
wanted
Andrea Landaker
qirien at icecavern.net
Sun Jan 11 13:17:38 EST 2004
> I want anything and everything, what I like best are useful snippets that
> actually do something. For example, Telsa posted this on one of the lists:
Well, I often have tons of zip files to deal with (like for getting resources
out of windows themes and dance steps for pyDance and modules for
NeverwinterNights and things like that), and they're not always formatted the
same way. Most of the time, I just want each zip file unzipped into its own
directory called the same thing as the zip file. So I do:
ls -Q *.zip | xargs -n 1 unzip-createdir
here's unzip-createdir:
#!/bin/bash
dirname="`echo $1 | sed -e 's/\.zip//'`"
mkdir "$dirname"
unzip -j "$1" -d "$dirname"
The -Q option to ls has it quote the files, so you don't get problems if the
files have spaces or quotes in them. It would be nice if find had a similar
option, but so far I haven't found one.
I guess it's kind of specialized, but I've used it a lot for the things I do.
--
Andrea Landaker
http://www.icecavern.net/~qirien/
More information about the Techtalk
mailing list