Skip to main content
1 of 2
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" 
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68