Re: [SLUG] text processing (lower case)

From: Eben King (eben01@verizon.net)
Date: Fri Sep 19 2008 - 17:56:59 EDT


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:
>
> #! /bin/sh
> while read line ; do
> case "z$line" in
> z) ;;
> z/*) firstcharlc="$(echo "$line" | sed 's@^.*/mp3/\(.\).*$@\1@' | tr
> A-Z a-z)"
> sed "s@^\\(.*/mp3/\\)\\(.*\\)\$@\\1$firstcharlc/\\2@" ;;
> *) echo "${line#z}"
> esac
> done < "$1"

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.

-- 
-eben      QebWenE01R@vTerYizUonI.nOetP      royalty.mine.nu:81

Q: What did one photon say to the other photon? A: I'm sick and tired of your interference. -- thebigmike1983 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:44 EDT