On Fri, 19 Sep 2008, Eben King wrote:
> On Fri, 19 Sep 2008, Eben King wrote:
>
>> On Thu, 18 Sep 2008, Daniel Jarboe wrote:
>>
>>> Oh, sorry. Some unix versions have an lcase comand. If not, write your
>>> own:
>>>
>>> sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
>>>
>>> tr A-Z a-z
>>
>> OK, I tried it with two "sed -e" commands and "sed | tr". The first was a
>> bit faster (like a few hundredths out of half a second or so) but (to me at
>> least) the second was way clearer. Here's what I settled on:
>
> Scratch that, it only works for spherical cows in a vacuum^W^W^W^Wbands
> starting with "A". Obviously I have more work to do.
OK, that's more like it. Given a file of about 1700 mp3s, it takes about 24
seconds.
#! /bin/sh
while read line ; do
case "a${line}z" in
az) ;;
a/*z) firstcharlc="$(echo "$line" | sed 's@^.*/mp3/\(.\).*$@\1@' | tr A-Z a-z)"
echo "$line" | sed "s@^\\(.*/mp3/\\)\\(.*\\)\$@\\1$firstcharlc/\\2@" ;;
*) echo "$line"
esac
done < "$1" | sed 's/^a\(.*\)z/\1/'
The problem was I wasn't doing the 'echo "$line |' part in the case, so that
sed was processing all of stdin which was the entire file.
-- -eben QebWenE01R@vTerYizUonI.nOetP royalty.mine.nu:81 Scientist A: A matterbaby is a very unstable particle. Scientist B: What's a matterbaby? Scientist A: I'm doing fine honey, how you doing? -- mrshowrules on Fark ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:58:51 EDT