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
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
A line of AWK seemed to work.
awk '{print > "Out"$1".dat"}' file.out
Labels: unix

0 Comments:
Post a Comment
<< Home