Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK program - Help Needed

Status
Not open for further replies.

blx

MIS
Oct 9, 2002
23
GB
Hi All,
I have the following line:
1944512883.1.347#TMF_ManagedNode::Managed_Node#

I want to use AWK to extract 1944512883.1 only and then discard everything else after the '1'.

I'd be really grateful if someone could show me how or tell me if this can be done.

Thanks VM in advance.

 
nawk 'BEGIN { FS="."} {print $1 FS $2}' yourfile

HTH
Dickie Bird (:)-)))
 
Hi blx,

with "cut" (I think this is faster than awk):
grep Managed yourfile | cut -d. -f1-2

with "awk":
awk -F. '[ print $1 "." $2 } yourfile

or a bit more flexible (but slower) with "nawk":
first create a Variable like $DELIMITER="."
nawk F$DELIMITER -v del=$DELIMITER '{ print $1 del $2 }' yourfile

HTH

mrjazz [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top