Read delimted text file from & extract lines

July 17, 2009 at 15:32:53
Specs: Windows XP
I need to use a batch file that will open a text file that is formated like this:

DID_ID RUN_NUM SUB_RUN REC_TYPE CDV_CODE CDN_CODE SUM_CODE SUM_TYPE BCL_CODE AMOUNT CREATE HOME_CDN_CD ALLOCATION
68 8 D 0200 FI T B137 244.77 0200
68 8 D 0200 FR T B137 244.77 0200
68 8 D 0200 MC T B137 57.26 0200
68 8 D 0200 EM T B137 57.26 0200


It is tab delimited and i need to save only lines that contain XX in space 4&5, may be 1 or 2 digits in length.


See More: Read delimted text file from & extract lines

Report •


#1
July 17, 2009 at 17:01:09
from the sample file format you provided, show the final output you want. i don't see any XX in your file.

GNU win32 packages | Gawk


Report •

#2
July 20, 2009 at 07:35:19
Sorry the XX is represented by the following:

68 XX D 0200 FI T B137 244.77 0200

Where this could be one or two numbers. Such as the following:

68 12 D 0200 FI T B137 244.77 0200
85 8 D 0200 FI T B137 244.77 0200
58 24 D 0200 FI T B137 244.77 0200

So as you can see first two groups of char can change, but the one that i need to filter is the second group. For example, i only what to work with the lines that have the "12" in the 4-5 position.

I do have gawk, so if that works i can use it too.


Report •

#3
July 20, 2009 at 09:05:14
awk '$2==12' file

GNU win32 packages | Gawk


Report •

Related Solutions

#4
July 20, 2009 at 09:36:00
Will this extract the lines and put them into a separate file? I need to run this command in a batch file that loops thur several hundred files and extracts the lines that are specified in the variable.

Overwriting the original file using the same name, also need the option to keep the header line.


Report •


Ask Question