merlyn@iwarp.intel.com (Randal Schwartz) (05/04/90)
In article <757@sagpd1.UUCP>, jharkins@sagpd1 (Jim Harkins) writes: | I need to change a lot of words with mixed upper and lower case letters into | words of all lower case letters, from there I'm going to make a sed script | to actually modify the words in our source. So how do I make my list? | For example, I want to convert the list | | FooBar | blaTZ | GRMblE | WhEe | | into | | FooBar foobar | blaTZ blatz | GRMblE grmble | WhEe whee | | (from this second list it's trivial to create lines of sed commands like | '/FooBar/foobar/g', and there are around 800 words in my list) | | Right now I have 2 files, one with the upper/lower case names, the second | with just lower case names. I think I've been going down the wrong path | here though. I'm now thinking of using sed directly but I'm no sed wizard. | Join may also do the job but I'm having trouble deciphering the man page | and none of my experiments to date have remotely resembled what I'm after. | | So, has anyone got any advice (outside of having a flunky use vi :-)? | Thanks in advance. An all-in-one Perl solution... ################################################## snip snip #!/usr/local/bin/perl @names = split(/\n/, <<END_OF_NAMES); FooBar blaTZ GRMblE WhEe END_OF_NAMES $cmd = "study;\n"; for $name (@names) { ($lcname = $name) =~ y/A-Z/a-z/; $cmd .= "s/\\b$name\\b/$lcname/g;\n"; } while (<>) { eval $cmd; print; } ################################################## snip snip printf "%s", "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@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
jharkins@sagpd1.UUCP (Jim Harkins) (05/05/90)
In article <1990May4.004643.1994@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: >In article <757@sagpd1.UUCP>, jharkins@sagpd1 (Jim Harkins) (thats me) writes: >| I need to change a lot of words with mixed upper and lower case letters into >| words of all lower case letters, from there I'm going to make a sed script >| to actually modify the words in our source. So how do I make my list? I got my answer to this, thanks to all who responded. The pattern of responses was interesting. I posted the request just before leaving last night, and this morning I had 5-6 replies with variants of sed scripts. Then during lunch I got another batch of replies and these were all suggesting a tool called patch, with nary a soul mentioning sed. Interesting. Anyway, thanks for the help. -- jim jharkins@sagpd1 My new investment plan GUARENTEES a 50% rate of return! Just mail me $10,000 and I promise you'll get $5,000 back.