waider: (Default)
waider ([personal profile] waider) wrote2005-05-16 12:05 pm
Entry tags:

why you should document things, no matter how small.

Waider (mayo.dev.ie.alphyra.com) $ > cat gnee
1109 find . -type f | perl -ne ‘while(<>) { chop; $f=$_; $f=~s|^./([^/]+)/|$1:|; $f=~s|/([^/]+)$|.\U$1|; $f=~s/\//-/g; system(“mv $_ $f\n”)}’
Waider (mayo.dev.ie.alphyra.com) $ >

Um. Yes. Looks like it might uppercase filenames and do something like replacing slashes with dashes, but I’m certainly not running it to find out.

[identity profile] pobig.livejournal.com 2005-05-16 11:33 am (UTC)(link)
This kind of thing reminds me of how Pak Protectors' technology tended to be rather shaky in Larry Niven's stories, since most of it was improvisation and they figured they could fix it if it went out of spec.

These days I usually have scripts echo what I want done, and then remove the safety and re-run them if it looks OK.
ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-05-16 11:51 am (UTC)(link)
Normally if I'm doing stuff I might conceivably need again, I'll put it in a file with a comment as to what it's doing. The above was evidently a one-off that I felt, er, proud enough of to save.

[identity profile] mskala.livejournal.com 2005-05-16 12:24 pm (UTC)(link)
Using -n along with while(<>) is a very odd thing to do. I think that's most likely a bug; its apparent effect will be to skip over the first file found by find. It looks to me like this script is designed to munge the output of wget. It changes paths like "foo/bar/baz/dat" into single-level filenames like "foo:bar-baz.DAT". That might be something you'd want to do if you had just downloaded a bunch of stuff with wget and wanted to tidy it up. wget offers options to NOT create a deep directory tree, though, and it would probably be easier to use those options and then have less work to do with perl.
ext_181967: (Default)

[identity profile] waider.livejournal.com 2005-05-16 12:41 pm (UTC)(link)
Thanks, Matt. The next time I need a critique (that completely misses the point I was making) of a one-liner from six years ago, I'll be sure and contact you directly.

[identity profile] sambushell.livejournal.com 2005-05-16 04:12 pm (UTC)(link)
Schmeh. You complain about perl readability, you get what you get.