Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: sed ?



--------------------------------------------------------
tlug note from Jim Schweizer <schweiz@example.com>
--------------------------------------------------------
Hi all,

After the great help a couple of weeks ago on using sed to strip
headers from email I decided to try to learn a little more about
it. So, I ordered the O'Reilly 'sed & awk' book and got to work.

The problem is, sometime things don't work as advertised. For
example in chapter 3 you're supposed to make a program for
making single replacements called 'gres' which looks like:

jim:~/bin$ cat gres
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

When I try to use it though I get the error:

sed: Unknown option to 's'

So I tried in on both my Slackware setup and SparkLinux with the
same result.

The book was written and tested on a SparcStation 1 running
SunOS 4.0. Is the Linux sed version different? I'm using GNU sed
version 2.05; should I upgrade?

Thanks,

Jim S.

----------------------------------------------
Sent by: Jim Schweizer <schweiz@example.com>
On: 23-Apr-97 at: 10:22:42 JST
http://www1.harenet.or.jp/~schweiz/
"I thought you were trying to get into shape."
"I am. The shape I've selected is a triangle."
----------------------------------------------
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links