Selective translation
Randal Schwartz
merlyn at iwarp.intel.com
Wed Jul 11 07:53:08 AEST 1990
In article <1553 at dfsun1.electro.swri.edu>, jackson at dfsun1 (Keith Jackson) writes:
| I was trying to filter a file by making the first word lowercase and
| leaving the rest as is. My solution:
|
| % awk -f filt1.awk foo | tr A-Z a-z > stage1.b
| % pr -m -t -s -l1 stage1.a stage1.b > final
|
| where filt1.awk contains:
| {
| print $1;
| for (i = 2; i < NF; i++)
| printf("%s ", $i) >> "stage1.a";
| if (NF > 1)
| print $NF >> "stage1.a";
| }
I hope you mean "the first word on each line". That's about the best
I could come up with by reverse-engineering your code. In Perl, it'd be:
perl -pe 's/^(\W*\w+)/(($x = $1) =~ tr|A-Z|a-z|),$x/e' foo
Just another Perl hacker,
--
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
More information about the Comp.unix.questions
mailing list