for Unix Gurus [message #58419] |
Mon, 25 August 2003 18:04 |
sidd
Messages: 130 Registered: May 2003
|
Senior Member |
|
|
i have a following data file i need to split it into 2 files
datafile xxxx.txt
adsfasd|adsfasd|adsfasd|adsfasd
fdgfdgfdsfs ~
adsfasd|adsfasd|adsfasd|adsfasdfdsafdsa ~
adsfasd|adsfasd|adsfasd|adsfasd
asdfad
dfasdfads
dsafadsfdsafdsa asdfa dfa ~
adsfasd|adsfasd|adsfasd|adsfasd ~
say this file has 4 recds i want to split it into 2 files using unix commands or script and each should have 2 rcds. this is an eg. i have very huge file.. how should i do this.
|
|
|
Re: for Unix Gurus [message #58432 is a reply to message #58419] |
Tue, 26 August 2003 09:01 |
Marks
Messages: 11 Registered: February 2002
|
Junior Member |
|
|
On hp-ux you can :-
split -2 filename
the above means split into 2 line chunks.
If you want to automate splitting a file in half you could use "wc -l filename" to determine how many lines in the source file, assign this to a variable and use the variable as the first parameter.
LINES=`wc -l filename`
VAR=`expr $LINES / 2`
split $VAR filename
|
|
|