Find the answer to your Linux question:
Results 1 to 2 of 2
Hi everyone, I'm trying to save multiple outputs to the same file, thus I want it to add the new output to the end of the existing file. Instead it ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Location
    Halifax, NS
    Posts
    19

    Add to file without overwriting

    Hi everyone,

    I'm trying to save multiple outputs to the same file, thus I want it to add the new output to the end of the existing file. Instead it just overwrites the file with the new output and all the old output is lost.

    What I have right now is basically like this:
    Code:
    for loop
    do
     statements
    done > ~/path/file.txt
    
    more for loops that write to the same file
    edit: this is for a bash script.

    Thank you hazel.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    Use >> instead of > and bash will go into append mode.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

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