LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-21-2009, 06:43 AM   #1
{LCD}STELIOS
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, 06:53 AM   #2
rizhun
Member
 
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, 07:49 AM   #3
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
Code:
split -b 1260m
 
  


Reply


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 11:40 AM
awk command to split file Hebron Linux - Newbie 3 08-27-2007 08:35 PM
Split Command... How to Rejoin? Quantumstate Linux - Software 2 11-03-2006 03:49 PM
split command in perl not splitting / linuxmandrake Programming 1 11-03-2005 04:28 PM
command to split up directory by size? dr_zayus69 Programming 6 06-27-2005 04:12 AM


All times are GMT -5. The time now is 08:24 PM.

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