merging 2 files

Maarten Litmaath maart at cs.vu.nl
Sat May 5 06:41:41 AEST 1990


In article <757 at sagpd1.UUCP>,
	jharkins at 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 at cs.vu.nl, uunet!cs.vu.nl!maart



More information about the Comp.unix.questions mailing list