
03-18-2009
|
|
Registered User
|
|
|
Join Date: Mar 2009
Posts: 2
|
|
|
Sed options
I have a file with name input_file.spec.
This file has records like:
Record #: 1
rec_len = 590
rec_id = 31229
filler_4 = " "
orig_id = 902162988
seqnum = 138960799
lrnid = "0"
l_ind = "0"
transaction_cnt = 1
cust_id = 61032336
product_id = 135488621
ans so on.
It has 1000 records in this file.
I have to give new numbering to seqnum field only.
i am gogin to start with 1 and ll end with 1000.
I worte this:
#!/bin/ksh
i=1
echo "Give input file"
INPUTFILES=input_file.spec
cat $INPUTFILES | while read LINE
do
let i=i+1
sed -e '/seqnum/s/seqnum = [0-9]*/seqnum = '$i'/g' $LINE
done
but the "i" is not getting interpolated event when its reading line by line.
Can u please tell any option in unix to do the same.
or alternative to do the same business.
|