MY MALL

About | News | Google | Hotmail | Bizland




MY MALL

Friday, February 13, 2009

How To Split A UNIX File

Here is a solution to a minor programming problem I was working through last week.

The problem was to split up a large file consisting of many files of different lengths but with fixed columns and separate them by transaction code. There are a number of ways to do this with the magic of UNIX.

The UNIX utility csplit sometimes worked, but not always.

csplit -skf tran file.out "/tran code 1/" "/tran code 2 /"

A line of AWK seemed to work.

awk '{print > "Out"$1".dat"}' file.out

Labels:

0 Comments:

Post a Comment

<< Home

Google
 


Add to Technorati Favorites
Sedo - Buy and Sell Domain Names and Websites project info: mymallandnews.com Statistics for project mymallandnews.com etracker® web controlling instead of log file analysis