The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: AWK program
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-09-2009
sivakumar.rj sivakumar.rj is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 74
Question AWK program

Hi all,

I need to grep the 3 characters from a file, and to fetch the corresponding words to that character. My file is in the following format..

The below text will be in the separate file....say file2.txt

ABC This is the first text.
DEF This is the second text.
GH1 9.8.7890
AB1 This is the first1 text.
DE2 This is the second1 text.
GH2 19.8.7890
AB3 This is the first2 text.
DE3 This is the second2 text.
GH3 29.5.7890
AB4 This is the first3 text.
DE4 This is the second4 text.
GH4 9.9.7890

Now I need to grep for GH1, 2, 3 ,4 records and extract the corresponding number upto 5 position..

i.e GH1 9.8.7, GH2 19.8.7...like this so on....and I have to add these number into another along with a text to the top. For example, in my file1.txt...I need to add like this...

The world is round 9.8.7
Today is my birthday 19.8.7

like this...I need to do it...Pls help on this...