Selective translation

Keith Jackson jackson at dfsun1.electro.swri.edu
Thu Jul 12 00:33:26 AEST 1990


) In article <8677 at jpl-devvax.JPL.NASA.GOV> lwall at jpl-devvax.JPL.NASA.GOV (Larry Wall)
) In article <1553 at dfsun1.electro.swri.edu> jackson at dfsun1.electro.swri.edu (Keith Jackson) writes:
) : I was trying to filter a file by making the first word lowercase and
) : leaving the rest as is.  My solution:
) : 
) : (cumbersome process deleted)
) 
) Well, there's
) 
) (many perl solutions deleted (gee, I thought she just sang ;^))
)
) or even
) 
)   sed -e 'h' \
) 	-e 's/^\([ ]*[^ ][^ ]*\).*/\1/' \
) 	-e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
) 	-e 'G' \
) 	-e 's/\n[ ]*[^ ][^ ]*//'  foo >final
) 
)     where [ ] and [^ ] can be expanded to have a tab as well.
) 
) Take your pick.  All of these will preserve the whitespace around the
) first word on each line, which you can't do very easily with awk.
) 
) Larry Wall
) lwall at jpl-devvax.jpl.nasa.gov

This sed solution seems to be the only one I've seen to keep whitespace
intact.  Another solution for those who don't care about spacing:

#! /bin/sh
while {read ab} do
{
    echo -n $a\# | tr A-Z a-z;
    echo $b;
}

Where # is whatever character you want to separate the two.
-- 
        ########  U N * X   :   L i v e   F r e e   o r   D i e ########
Keith Jackson {convex, texsun}!smu!jackson == jackson at csvax.seas.smu.edu
== jackson at dfsun1.electro.swri.edu
Disclaimer: They're not paying me for my opinons.  I'd starve.



More information about the Comp.unix.questions mailing list