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!

awk-ing to Multiple Files

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
US
I have a file whose fields are separated by '|' characters. I can't post it here due to confidentiality issues but each record looks something like this:

f1|f2|f3|f4|f4|f6|f7|C|f9|...

I need to examine each record and write the records to different files based on the value in field 8 ('C' in the example above). There are three possible values: C, O and E so there will be three files created each day when the script runs.

So far I've managed to extract the records of interest from the much larger master file and have them ready to break out into the three files ... but I'm stuck. Was thinking I could do it with awk but no combination I've tried is working.

Comments/thoughts/suggestions appreciated.

Thanks in advance.

Tom

"My mind is like a steel whatchamacallit ...
 
outfile= $8 ".txt"
printf "........" >> outfile

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Guess I'm not sure how this would tie into an awk command ... ?

"My mind is like a steel whatchamacallit ...
 
it's part of your awk "command"

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Ahhhhhhhhhhhhhh ... wasn't making the connection. Sorry - I've been slammed here at work this morning and am trying to do 4 or 5 different things all at once (they're all "more important than anything else you're doing right now" kind of things ... :))

Thanks.

"My mind is like a steel whatchamacallit ...
 
Solved with the help of a Unix guru here at work ...

We weren't able to do it in .ksh script ... awk didn't like the number of fields in some of the messages (exceeded the 1024 field limit) so ended up writing a Perl script to remove the ^M between each line so the entire record was treated as a single (huge) line. We then split the field on the '|' characters and pulled out the two fields I really needed.

Thanks for the assist on this. I really appreciate it!

Tom

"My mind is like a steel whatchamacallit ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top