Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: merging 2 files Message-ID: <6450@star.cs.vu.nl> Date: 4 May 90 20:41:41 GMT References: <757@sagpd1.UUCP> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, The Netherlands Lines: 57 In article <757@sagpd1.UUCP>, jharkins@sagpd1.UUCP (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? Assume the file `word-list' contains the list of words to be changed, and the files to be processed are `file_1 file_2 ... file_N'. Then the following command will do what you want: lowercase word-list file_1 file_2 ... file_N ...where `lowercase' is the following shell script. Can you figure out why I `complicated' the `ex'-script? --------------------cut here-------------------- #!/bin/sh # @(#)lowercase 1.0 90/05/04 Maarten Litmaath # Usage: lowercase word-list [files] # use `-' for `word-list' if the list is supplied on stdin PATH=/bin:/usr/bin:/usr/ucb script=/tmp/foobar.$$ tmp=/tmp/glork.$$ umask 077 cleanup='rm -f "$script" "$tmp"' trap 'eval "$cleanup"; exit 2' 1 2 3 15 trap 'eval "$cleanup"; exit' 0 test $# = 0 && { set x - shift } cat "$1" > "$script" shift ex - "$script" << \EOF a . %s-.*-s/&/\L&/g- g-s///g-d x EOF test $# = 0 && { sed -f "$script" exit } for i do sed -f "$script" "$i" > "$tmp" && cp "$tmp" "$i" done -- Antique fairy tale: Little Red Riding Hood. |Maarten Litmaath @ VU Amsterdam: Modern fairy tale: Oswald shot Kennedy. |maart@cs.vu.nl, uunet!cs.vu.nl!maart