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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Specific Records from a File 2

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
US
I have a file - each record quite long - which starts out in the following general format:

Code:
07/11/2007 00:00:10|field2|07112007|field4|MSH|^~\&|SPC|[COLOR=red]O[/color]|IM|E|

and I need to be able to select only records with an O in the indicated location - everything else to be ignored.

I had thought that using something like

Code:
facind=`awk 'BEGIN{FS=OFS="|"}{print $8}' homl.work

would put the value of that field in variable facind but I can't get it to work.

Would appreciate someone pointing me in the correct direction.

Note that the system is AIX 5.2 using Korn shell.

Thanks!

Tom

"My mind is like a steel whatchamacallit ...
 
Why not simply this ?
Code:
awk '$8=="|"' homl.work

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Probably because I always overcomplicate things ... :)

Thanks gain, PH - you keep saving my 'bacon' here.

Tom

"My mind is like a steel whatchamacallit ...
 
Pardon me asking PHV, but how can that work?
Thought you had to do like this:
Code:
awk -F'|' '$8=="O"' homl.work
to "select only records with an O in the indicated location"
But then I'm no AWK-expert... ;-)

 
I must confess I've typed too fast and you're absolutely right geirendre.
I suppose Tom got the idea and corrected my typos.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top