Re: Need to print 2 chars (or ints) from a string, sugestions?
- From: "William James" <w_a_x_man@xxxxxxxxx>
- Date: 16 Feb 2006 16:55:29 -0800
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'
.
- References:
- Need to print 2 chars (or ints) from a string, sugestions?
- From: ponga
- Re: Need to print 2 chars (or ints) from a string, sugestions?
- From: William James
- Need to print 2 chars (or ints) from a string, sugestions?
- Prev by Date: Re: gawk vs. nawk portability issue
- Next by Date: Re: gawk vs. nawk portability issue
- Previous by thread: Re: Need to print 2 chars (or ints) from a string, sugestions?
- Next by thread: Re: Need to print 2 chars (or ints) from a string, sugestions?
- Index(es):
Relevant Pages
|