Mail Archives: djgpp/1998/11/12/15:16:16
Hi all,
I'm learning awk and sed got the book. It has the following program
as a work round for gres not being in a Unix distribution. I'm running bash
1.14.7 and sed 3.02
I.e. the normal djgpp stuff for PC.
The line ... A="`echo | tr '\012' '\001'`" ... is to ensure
portability. However what we have gives
"unknown option to s". I changed the line:- from
sed -e "s$A$pattern$A$replacement$A" $file
To
sed -e "s/$pattern/$replacement/" $file
This change has helped no end. Once again your comments will be of
enormous help. Also should I be in a login or interactive mode?
Regards Ian.
#! /bin/sh
if [ $# -lt "3" ]
then
echo Usage: gres pattern replacement file
exit 1
fi
pattern=$1
replacement=$2
if [ -f $3 ]
then
file=$3
else
echo $3 is not a file.
exit 1
fi
A="`echo | tr '\012' '\001'`"
sed -e "s$A$pattern$A$replacement$A" $file
- Raw text -