Results 1 to 2 of 2

Thread: SPLIT command

  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    SPLIT command

    Hi All

    I have a file that has over 5,00,000 records and I want to split the file into 65,500 rows.

    I am able to split the file into 7 files using SPLIT command. I want to know if it is possible to attach a header for all the 7 files using a single script or a single command along with the SPLIT command. Help would be very much appreciated.


    Thanks
    Sharath


  2. #2
    Junior Member
    Join Date
    Jun 2007
    Answers
    9

    Re: SPLIT command

    you can use -lnumber to tell split how many rows (or record if a row is a record) will be each file.

    split -l65000 mi_huge_file_500000

    after that split will create the files xaa, .... etc...
    if you want to put a header on each file create the header file and later do a cat on the following way:

    cat xaa >> header_file

    will append xaa to the header file, but becareful if you want to use the same header, you must replicate it, so you don't lose it.
    En fin... try with a script something more elaborated...
    I recommend you the advanced bash scripting guide
    http://www.tldp.org/LDP/abs/abs-guide.pdf

    HTH


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact