Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all Everything is a first once, and here is my first post. I'm curious about the low level functionality of cat. The background is that I have a script ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Location
    Stockholm
    Posts
    4

    append files, or low level 'cat'

    Hi all
    Everything is a first once, and here is my first post.

    I'm curious about the low level functionality of cat. The background is that I have a script that calibrates datafiles and after calibration appends them total calibrated file.
    The problem is that this collected file quickly grows and easily reach >500Mb, when running the append command
    > cat COLLECTED_FILE NEW_FILE > NEW_COLLECTED_FILE
    I can go and have a cuppa because the computer completely grinds to a halt for a while.

    My understanding is that cat reads in the old file, the new file and then append them thus there is a lot of reading and writing when the files grow.
    Is there a way to speed up this process, or do I have to do these things at night?

    Thanks

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Just append to the existing file.

    Code:
    # cat NEW_FILE >> COLLECTED_FILE

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Yep. That way you avoid having to read one of the files.

    Also, you can use "nice" to set up a better niceness for that process so it's softer in terms of cpu. If udma is on, your box shouldn't be irresponsive when doing this though. If so, then there's some problem at some level.

    Using a sane fs (read, anything but reiserfs) will probably also save you some cpu cycles.

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Just append to the existing file.
    Faster, but not recommended if you're worried about the system or the process dying before the appending is finished. It depends on how bulletproof this situation needs to be.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Just Joined!
    Join Date
    Nov 2008
    Location
    Stockholm
    Posts
    4
    *thump*, the sound of my head against the desk...

    I knew there was a better way! Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...