# renum.sh Renumbers a bunch of sequences # that are already formatted. Skips lines that don't begin with % # First argument is input file name, second is first free A-number # Note to myself: remember to maintain the link # ln renum.sh /usr/njas/wwwfiles/sequences/renum.sh.txt # If you download this from my web page, it is important to # use the SOURCE FILE. DON'T mouse it off the screen # because many of the characters will not be visible. # Call this file renum.sh (not renum.sh.txt) # Corrected Nov 19 2002 # Modified Nov 02, 2002 # Modified Oct 08, 1999. # Set version of awk to use: AWK=/bin/gawk if [ "$#" -ne 2 ] then echo "Incorrect no of arguments. Usage: renum.sh infile 14376 >out " exit 1 fi $AWK ' BEGIN { at = '$2' - 1 } $1 ~ /%I/ { printf("\n"); at = at + 1 ; # Pad length of at to 6 digits t1 = at while ( length(t1) < 6 ) t1 = 0 t1 t2 = "A" t1 } $0 ~ /^%/ { sub($2, t2); print } END { printf("\n")} ' $1 | sed '1d'