Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Extracting pattern only with AWK or SED  RSS feed

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have the following statement working, but when we move the program to Solaris 10 it fails.



How can we use AWK or SED to extract only the 6 digit number from the string?

The following outputs the entire string. We only want the 6 digit number.




Thanks.
[ August 21, 2008: Message edited by: James Clark ]
 
author & internet detective
Sheriff
Posts: 38027
605
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
Take a look at the print section of this tutorial. It shows how to use the longer form of awk to just print out a specific argument. The short form that you are using prints out the whole line.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you much.

Below are sed commands that do the trick.



Or

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!