#!/bin/ksh # reseq.ksh by Dan Martin (DRM/CTG) Fri Nov 17 15:28:33 CST 2000 infi="emsaccdata.txt" # Input File clear cat << BOX ALERT: The file "$infi" will be read and the Sequence Number (first field of each record) will be renumbered beginning with the number you enter below. File "$infi" will not be altered in any way. BOX ans="" while [[ -z "$ans" ]] do echo "Enter New Sequence Number: \c" read ans done outfi="`basename ${infi} .txt`_${ans}.txt" # Output File awk -F"," -v seq="$ans" ' { outs = sprintf("%s,", seq) for (i = 2 ; i < NF; i++ ) outs = sprintf("%s%s,", outs, $i) outs = sprintf("%s%s", outs, $NF) ++seq print outs }' $infi >$outfi echo "\nThe new Output File is: \"$outfi\".\n" # EOF