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!

Extract Info from Fixed Length file

Status
Not open for further replies.

skb2005

IS-IT--Management
Mar 8, 2005
129
Hi Unix Guru's,

I have a fixed length format text file. I need to extract some information and save into another file.

Sample File format:

5IW8002240999 0001143324950059400999200703012007030104544804571200002248002240999

I need to extract the information enclosed in quotes as seperates columns, seperated by "|".

"5"IW8002240999 00011433249500"59400999"20070301"20070301"0454480457120000248002240999

The new File should look like
5|59400999|20070301

 
man awk (the substr function)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the quick response. I just landed to UNIX world, probably will take some to get used to.

Any example would make my life easy.

Thanks again.
 
Maby this does it:
Code:
awk '{ print substr($0,1,1)"|"substr($0,42,8)"|"substr($0,50,8) }' fixedlenght.txt > result.txt
:)
 
Thanks for the quick help. That really worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top