RE: shell script
Posted in 1998
awk -F'|' '{ OFS="|"; $1 = count++; print $0; }' input > output Assuming that the delimiter is '|'. Tested on a trivial file and seemed OK. Won't work happily if any of the records contain multi-line character/blob fields. You can put the OFS into a BEGIN section, and set count to something other than 0 to start with if desired. The other possible variants are legion, and definitely include using Perl instead of awk. Yours, Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h> ---------- From: oss96@batelco.com.bh[SMTP:oss96@batelco.com.bh] Sent: Wednesday, March 25, 1998 3:01 PM To: informix-list@iiug.org Subject: shell script Hi unix gurus, I have a 16 MB ascii file containing about 80 thousands row (output from prevouis unload), I want to write a shell script that scan the file and update the first field in each row by an integer number which will be then incremented sequentially on all the rows till the end of the file. environement: sco unix + informix 5.0 Thanks to all O.Osman