Skip to main content
added 73 characters in body
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

awk is always trying to interpret $<something> as a field value (e.g. $0 - the whole record, $3 - the third field, $NF - the last field value)

Pass directory name via variable:

awk -v dir="$TRANSDIR" '/FILE-HDRPQ/{x=substr ($0,11,6)} NR>1{print $0 > dir"/"x"_prchgrpt.txt";}' "$TRANSDIR/$prcfile" 

awk is always trying to interpret $<something> as a field value (e.g. $3)

Pass directory name via variable:

awk -v dir="$TRANSDIR" '/FILE-HDRPQ/{x=substr ($0,11,6)} NR>1{print $0 > dir"/"x"_prchgrpt.txt";}' "$TRANSDIR/$prcfile" 

awk is always trying to interpret $<something> as a field value (e.g. $0 - the whole record, $3 - the third field, $NF - the last field value)

Pass directory name via variable:

awk -v dir="$TRANSDIR" '/FILE-HDRPQ/{x=substr ($0,11,6)} NR>1{print $0 > dir"/"x"_prchgrpt.txt";}' "$TRANSDIR/$prcfile" 
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

awk is always trying to interpret $<something> as a field value (e.g. $3)

Pass directory name via variable:

awk -v dir="$TRANSDIR" '/FILE-HDRPQ/{x=substr ($0,11,6)} NR>1{print $0 > dir"/"x"_prchgrpt.txt";}' "$TRANSDIR/$prcfile"