Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
to split a file
Name: nicolas Date: August 21, 2003 at 03:08:42 Pacific OS: ksh CPU/Ram: ?
Comment:
Hello,
I have to split a fil in several parts. I need to cut it in blocks delimited by 2 particular lines. What is the best tool to do that ? (or can anyone give me a piece of programm that can do that) Thank you for your help.
Name: cc0537 Date: August 21, 2003 at 05:51:44 Pacific
Reply:
read up on awk
0
Response Number 2
Name: James Boothe Date: August 21, 2003 at 06:20:52 Pacific
Reply:
This program compares entire line ($0). Instead, you can trigger on a certain field like if ($1=="HEADER"), or match any part of a line like if match($0,"part of the line").
#!/bin/sh
awk 'BEGIN \ {outfile="outfile1"}
{if ($0=="this line begins file2") outfile="outfile2" else if ($0=="this line begins file3") outfile="outfile3" else if ($0=="this line begins file4") outfile="outfile4" print > outfile }' infile
Summary: Hi, I am trying to split a file which has fixed 10 rows into two files in PERL. The first 5 rows into fileA and the last five rows into fileB. I have to do this in a loop because I have multiple files...
Summary: Hi, I will have to split a 4 MB file into four 1 MB files. But the problem here is the first line is a header and the last line is a trailer. In between I have second level header which can repeat (2H...