Subject: Re: shell script question (grep)
To: Peter Seebach <seebs@plethora.net>
From: Lubos Vrbka <shnek@chemi.muni.cz>
List: netbsd-help
Date: 02/09/2003 18:32:08
> How many lines are there in file 2?
it can vary, from small to large numbers (20000, but could be even more),
but time isn't problem... :o)

> while read i j < file2
> do sed -e "s/$i\$/$j/" < file1 > file1.out
> mv file1.out file1
> done
looks fine, thank you for help... i thought it could be somehow done using
sed, but didn't know why :o)

just one question. what if the numbers being replaced will look like:
.... 580
.... 1580
.... 2580

and in the "translation table" there will be
580    value1
1580  value2
2580  value3
won't sed substitute it to
value1, 1value1 and 2value1?
should the sed command then be modified to
"s/\ $i\$/\ $j/"
to work properly? i'm not used to use sed (in fact, this is the first time
i'll be using it - i've never used it before; i'll take a closer look now,
seems to be very powerful and very useful :o))), so my comment may by
false...
>
> It's inefficient, but who cares?  This does the whole thing, and if it
takes
> a while to run, go watch a movie or something.
well, if the analyze performed before this step takes 5 hours (at least), i
think that few minutes won't hurt :o)

regards,
lubos