Ooops, that should be
#!/bin/bash
LINES = `wc -l domain-list`
LINES = $LINES / 2
split -C $LINES domain-list
Save that as e.g. 'splitdomains.sh'
Main Topics
Browse All TopicsI use this command in a script: ls /home/httpd/vhosts/ > domain-list
and the output is something like this :
domain1.tld
domain2.tld
etc etc ..
the are almost 1200 domains.
My question is... is there any way to run a command that would "split" the text file, in two depending on the lines inside the file ?
for e.g. if there are 1200 lines it would split it in two files list-1.txt with lines 1-600 and list-2.txt with lines 600-1200
or is there any other way ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: jkrPosted on 2007-03-03 at 10:21:08ID: 18647764
You could do that like
#!/bin/bash
LINES = `wc -l domain-list`
LINES = LINES / 2
split -C $LINES domain-list
'split wokrs like
NAME
split - split a file into pieces
SYNOPSIS
split [OPTION] [INPUT [PREFIX]]
DESCRIPTION
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab,
...; default PREFIX is `x'. With no INPUT, or when INPUT
is -, read standard input.
-b, --bytes=SIZE
put SIZE bytes per output file
-C, --line-bytes=SIZE
put at most SIZE bytes of lines per output file
-l, --lines=NUMBER
put NUMBER lines per output file
-NUMBER
same as -l NUMBER