Google Answers Logo
View Question
 
Q: bash unix script ( No Answer,   1 Comment )
Question  
Subject: bash unix script
Category: Computers
Asked by: masterofdeals-ga
List Price: $5.00
Posted: 07 Mar 2005 19:05 PST
Expires: 06 Apr 2005 20:05 PDT
Question ID: 486500
how i cand split a huge file into multiple small files ?
Answer  
There is no answer at this time.

Comments  
Subject: Re: bash unix script
From: turkyman-ga on 08 Mar 2005 06:01 PST
 
To split large files into smaller files in Unix, use the split
command. To do so, at the Unix prompt, enter:

  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 you use the  -l  (the letter 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 myfile is 3,000 lines long. 
  split myfile
This will output three files, xaa, xab, and xac, and each one will be
1,000 lines long.


Working on the same file, this next example is more complex: 
  split -l 500 myfile segment
This will output six 500-line files: segmentaa, segmentab, segmentac,
segmentad, segmentae, and segmentaf.


Finally, assume myfile is a 160KB file: 
  split -b 40k myfile segment
This will output four 40KB files: segmentaa, segmentab, segmentac, and segmentad. 
For more information, consult the man page for the split command. At
the Unix prompt, enter:

  man split
You may also wish to investigate the csplit command, which splits
files based on context. For more information, see the man page for the
csplit command. At the Unix prompt, enter:

  man csplit

Reference: http://kb.indiana.edu/data/afar.html?cust=035665.12647.30

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy