I am running the following programs within one script. It works, however I would like a more professional way than to than to run 5 separate instances of awk. Any insight would be greatly appreciated.
Thanks.
nawk '/TABLE1/, /:TABLE2/' file | nawk -v X=$1 'BEGIN {FS=","} $3==X {len="%-8s"
printf "HEAD1\n"
printf len, "FIELD1"
printf len, "FIELD2"
printf len, "FIELD3"
printf len, "FIELD4"
printf len, "FIELD5"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
nawk '/TABLE3/, /TABLE4/' file |nawk -v X=$1 'BEGIN {FS=","} $3==X {len="%-8s"
printf "HEAD2\n"
printf len, "FIELDA"
printf len, "FIELDB"
printf len, "FIELDC"
printf len, "FIELDD"
printf len, "FIELDE"
printf len, "FIELDF"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
VAR=`nawk '/TABLE1/, /TABLE2/' file | nawk -v X=$1 'BEGIN {FS=","} $3==X {print $1}'`
nawk '/TABLE5/, /TABLE6/' file |nawk -v X=$VAR 'BEGIN {FS=","} $1==X {len="%-8s"
printf "HEAD3\n"
printf len, "FIELD"
printf len, "VALUE"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
nawk '/TABLE7/, /TABLE8/' file |nawk -v X=$VAR 'BEGIN {FS=","} $1==X {len="%-8s"
printf "HEAD4\n"
printf len, "ENTITY"
printf len, "VALUE"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
Thanks.
nawk '/TABLE1/, /:TABLE2/' file | nawk -v X=$1 'BEGIN {FS=","} $3==X {len="%-8s"
printf "HEAD1\n"
printf len, "FIELD1"
printf len, "FIELD2"
printf len, "FIELD3"
printf len, "FIELD4"
printf len, "FIELD5"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
nawk '/TABLE3/, /TABLE4/' file |nawk -v X=$1 'BEGIN {FS=","} $3==X {len="%-8s"
printf "HEAD2\n"
printf len, "FIELDA"
printf len, "FIELDB"
printf len, "FIELDC"
printf len, "FIELDD"
printf len, "FIELDE"
printf len, "FIELDF"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
VAR=`nawk '/TABLE1/, /TABLE2/' file | nawk -v X=$1 'BEGIN {FS=","} $3==X {print $1}'`
nawk '/TABLE5/, /TABLE6/' file |nawk -v X=$VAR 'BEGIN {FS=","} $1==X {len="%-8s"
printf "HEAD3\n"
printf len, "FIELD"
printf len, "VALUE"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'
nawk '/TABLE7/, /TABLE8/' file |nawk -v X=$VAR 'BEGIN {FS=","} $1==X {len="%-8s"
printf "HEAD4\n"
printf len, "ENTITY"
printf len, "VALUE"
printf "\n"
printf len"\n", $0, "\n"
printf "\n"}'