I am reading a file with awk, and because it is a fixed file using substr to select and write out parts of specific lines. However, one of my fields sometimes has extra characters. I know I can
awk 'substr($0,251,4)=="2008" {print substr($0,170,4)","substr($0,271,10)' $file_in >$fileout
But, that data at 271 for 10 characters might be
12345 which is good
12345a which I want to write as just 12345
in unix script, I could (assuming jbno contains my text)
jno=$(echo jbno | tr -d [a-zA-Z ])
to get rid of alpha characters and spaces
So, can something like that be done within an awk command?