twitter
Categories:- Unix Commands

How To Split Big File into Smaller Files in Linux

split command is used to to split large files into smaller files in Unix.. Syntax of Split command :

 

#  split [options]   filename   prefix

 

Replace filename with the name of the large file you wish to split. Replace prefix with the name you wish to give the small output files. You can exclude [options], or replace it with either of the following:

 

-l  linenumber
-b  bytes


If we use -l (a lowercase L) option, replace linenumber with the number of lines you'd like in each of the smaller files (the default is 1,000). If you use the -b option, replace bytes with the number of bytes you'd like in each of the smaller files.

The split command will give each output file it creates the name prefix with an extension tacked to the end that indicates its order. By default, the split command adds aa to the first output file, proceeding through the alphabet to zz for subsequent files. If you do not specify a prefix, most systems use x.

 

 

Examples  :

  • In this simple example, assume testfile is 3,000 lines long:

     

    # split testfile


    This will output three 1000-line files: xaa, xab, and xac.

     

  • Working on the same file, this next example is little complex:

     

    # split -l 500 testfile segment


    This will output six 500-line files: segmentaa, segmentab, segmentac, segmentad, segmentae, and segmentaf.

     

  • Finally, assume testfile is a 160KB file:

     

    #  split -b 40k   testfile segment

     

    This will output four 40KB files: segmentaa, segmentab, segmentac, and segmentad.

giri on, 2013-05-10 13:52:46
excellent work you r doing.. keep it up...thank u so much
Intakhab Khan on, 2013-08-10 05:15:08
Superb :) Very simple way of explaining with practical examples. Thanks Intakhab
Tarun on, 2014-02-07 06:19:02
Very helpful....
Daljeet Thakur on, 2013-10-18 09:16:51
Gud work keep up it............God bless u
lokeshvyas on, 2013-08-17 12:06:06
nic for learning . thanks.....
M.M.Ansari on, 2014-04-02 06:53:58
Simple Way.....................
Post Your Comments
Name:
Email:
Comment:
Security Code  *
Enter Security Code  *
Can't read the image? click here to refresh