![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl split question | ade214 | Shell Programming and Scripting | 5 | 10-14-2008 02:16 AM |
| Split large file and add header and footer to each file | ashish4422 | Shell Programming and Scripting | 1 | 04-15-2008 06:12 AM |
| Split a file with no pattern -- Split, Csplit, Awk | madhunk | UNIX for Dummies Questions & Answers | 10 | 12-17-2007 12:57 PM |
| Split and recombine question | white_raven0 | UNIX for Dummies Questions & Answers | 1 | 06-06-2007 11:42 PM |
| split question perl | reggiej | Shell Programming and Scripting | 7 | 07-21-2006 04:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a flat file in UNIX and I have to perform two tasks based on the below data. The data I have printed here is just sample the original data is too long.
The position 110 to 111 (two digit value I have bolded the values) theygives the record type detail in the sample above the record types in the sample are 32,32,31,31 and 35. The real data contains thousands of more records and there are more than 100 record types in a file. I have to split the file based on the record types in position 110 THRU 112. 000000008101 000011000700000000000000000000000001234567454002000 832I20090109 1234567097009967 123450007101 000000000000000000007856343446560000007856454540000 832I20090109 9864536670002456 957645465778 000011000700000000000000000000000067645333567743355 831I20090109 7854536670005647 676767497101 000011000700000000000000000000000008898675335767676 831I20090109 4565767665545469 767865444567 000011000700000000000000000000000007876564454676877 835I20090109 8786756656677887 TASK1: I have to split the file based on the record types. So the out put in this case will be three files File1 RecordType32 000000008101 000011000700000000000000000000000001234567454002000 832I20090109 1234567097009967 123450007101 000000000000000000007856343446560000007856454540000 832I20090109 9864536670002456 File2 RecordType31 957645465778 000011000700000000000000000000000067645333567743355 831I20090109 7854536670005647 676767497101 000011000700000000000000000000000008898675335767676 831I20090109 4565767665545469 File3 RecordType35 767865444567 000011000700000000000000000000000007876564454676877 835I20090109 8786756656677887 Can any body help me with a solution for this? I am not good at UNIX shell scripting TASK2: I need to get a unique list of record types in a file in my sample the result should be 32 31 35 |
|
||||
|
Is the part I highlighted in red a typo? Was it supposed to be ofile instead of type? I didn't test it- just seemed so...
Last edited by otheus; 03-09-2009 at 04:39 AM.. Reason: oops! |
|
||||
|
Quote:
Code:
awk '{_types[substr($3,2,2)]; print > "/tmp/type"substr($3,2,2)} END {for (i in _types) print i }' file > /tmp/type.list
Code:
awk '{_types[substr($3,2,2)]; print > "/tmp/type"substr($3,2,2)} END {for (i in _types) print i}' file | sort > /tmp/type.list
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|