linux - Printing all matches in a line using regular expression in awk -
say have line:
terminal="123" pwd="567"
i want select number portion using awk
awk 'match($1, /[0-9]+/){print substr($1, rstart, rlength)};match($2, /[0-9]+/){print    substr($2, rstart, rlength)}' file   this gives desired result.
123 567.
however there must other better way select both numbers without writing 2 match statements.
thanks.
here nice little solution awk:
awk '{gsub("[^0-9]+"," "); print}'   just converts consecutive non-digit characters 1 space, leaves 1 space before digit sequence 123.
Comments
Post a Comment