Home » RDBMS Server » Server Administration » for Unix Gurus
for Unix Gurus [message #58419] Mon, 25 August 2003 18:04 Go to next message
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&#124adsfasd&#124adsfasd&#124adsfasd
fdgfdgfdsfs ~
adsfasd&#124adsfasd&#124adsfasd&#124adsfasdfdsafdsa ~
adsfasd&#124adsfasd&#124adsfasd&#124adsfasd
asdfad
dfasdfads
dsafadsfdsafdsa asdfa dfa ~
adsfasd&#124adsfasd&#124adsfasd&#124adsfasd ~
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 Go to previous message
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
Previous Topic: Modules
Next Topic: CLOB Index
Goto Forum:
  


Current Time: Fri Sep 20 09:25:50 CDT 2024