Re: Need to print 2 chars (or ints) from a string, sugestions?



William James wrote:
ponga wrote:
Hello, I'm new to awk, so forgive my ignorance...

I have a shell script that outputs this line:
D54C

All I want to do, is extract the integer from this string. The 54 in
this case can be treated as chars, just the same. The 54 (the integer)
in this case, is always changing (output can be D62C, D41C, etc.) - but
the pattern is always the same.

Can someone give me an easy way awk can give me this output:
54
? In other words, just extract the integer, or the second and third
char, whichever is easier?

TIA!
-Jason

awk '{print substr($0,match($0,/[0-9]/))+0}'

awk '{gsub(/[^0-9]/,"")}8'

.



Relevant Pages