Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-21-2009, 05:43 AM   #1
LQ Newbie
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Split Command

What would be the split command for a 2.52gig .txt file if I wanted to split it in half?
Old 08-21-2009, 05:53 AM   #2
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
If it's an even number of lines, this will create 2 files:

$ halfsize=$(( $(awk 'END {print NR}' mymassivefile.txt) / 2 )) && split --lines=$halfsize mymassivefile.txt

If it's an odd number of lines it will create 3 files (the last one containing a single line).
Just append it to the end of the other file:

$ cat xac >> xab
Old 08-21-2009, 06:49 AM   #3
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
split -b 1260m


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use split function with AWK command? intikhabalam Linux - General 4 07-29-2008 10:40 AM
awk command to split file Hebron Linux - Newbie 3 08-27-2007 07:35 PM
Split Command... How to Rejoin? Quantumstate Linux - Software 2 11-03-2006 02:49 PM
split command in perl not splitting / linuxmandrake Programming 1 11-03-2005 03:28 PM
command to split up directory by size? dr_zayus69 Programming 6 06-27-2005 03:12 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration