Results 1 to 3 of 3
I am using gawk and need a regular expression that will return the version information ONLY.
My input file is the following:
xline 1
xline 2
3.3.6.4
the next line ...
- 04-21-2008 #1Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
need regex to return version information only
I am using gawk and need a regular expression that will return the version information ONLY.
My input file is the following:
xline 1
xline 2
3.3.6.4
the next line 4.2.45.3 is here
I want to return:
3.3.6.4
4.2.45.3
My current expression:
awk --re-interval '{
for(i=1;i<=NF;i++) {
if ( $i ~ /^([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}$/ ) {
print $0
}
}
}' "file"
returns
======
3.3.6.4
the next line 4.2.45.3 is here
What is missing?
- 04-22-2008 #2Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
The basic issue is that you're printing out $0 (the entire line) when your pattern matches.
I'm sorry I don't the syntax for carrying over your match and only printing that for gawk, but if you can figure that out, it's the only problem
Best wishes,
Mike
- 04-22-2008 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
you are going over the fields, so just change print $0 to :
print $i


Reply With Quote