Computing.Net > Forums > Unix > extracting few characters from file

extracting few characters from file

Reply to Message Icon

Original Message
Name: trichyselva
Date: January 1, 2008 at 23:08:09 Pacific
Subject: extracting few characters from file
OS: windows xp
CPU/Ram: p4
Model/Manufacturer: pentium
Comment:

i want to extract few characters from a flat file using special character || as field separator
how to do it
suggestions please


Report Offensive Message For Removal


Response Number 1
Name: James Boothe
Date: January 3, 2008 at 07:51:50 Pacific
Subject: extracting few characters from file
Reply: (edit)

Here is a file with columns delimited by double bar characters:

aaa||bbbbb||cc
xxx||Happy New Year||yyyyy

The following code will locate lines having "xxx" in column 1, and will print column 2 from each of those lines:

awk -F"[|][|]" '$1=="xxx" {print $2}' infile

Happy New Year


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: extracting few characters from file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge