Subject: Re: shell script question (grep)
To: Lubos Vrbka <shnek@chemi.muni.cz>
From: David Laight <david@l8s.co.uk>
List: netbsd-help
Date: 02/09/2003 18:46:46
On Sun, Feb 09, 2003 at 04:42:14PM +0100, Lubos Vrbka wrote:
> hi,
> sorry for a stupid (and slightly off-topic) question, but i cannot find a
> solution myself :o( i'm writing a shellscript for following purpose:
>
> i've 2 files: first file contains 7 columns, in the last one there's a
> number A. A isn't unique, it may occur on any number of lines. in the second
> file i've a "translation table", i.e. for every number A, there's given
> some other number B. there the A values are unique. now i want to replace
> all A values in the first file with the appropriate B values from the second
> file.
Why not just write a shell script!
This one will work if the 'tags' are alphanumeric.
David
#! /bin/sh
exec < file2
while read tag value
do
eval tag_$tag=\"\$value\"
done
exec < file1
while read line
do
set -- $line
eval echo tag_$7
done
--
David Laight: david@l8s.co.uk