Find the answer to your Linux question:
Results 1 to 3 of 3
I want to have the output of a program go to 2 different files but not going to standard out. Is there a way to do this in bash? I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    15

    [SOLVED] Pipe output to 2 files but not STDOUT


    I want to have the output of a program go to 2 different files but not going to standard out. Is there a way to do this in bash? I know that in Z shell its really easy. Something like:

    Code:
    echo "test" >> file1 >> file2
    Would work. But in Bash it doesn't seem that easy. I know that tee will send the output to 2 files but it also sends it to STDOUT. Something like:

    Code:
    echo "test" | tee -a file1 file2
    Would put the word "test" in file1, file2, and STDOUT. Is there a way to just send the output to file1 and file2?

    Anyway thanks in advance for any suggestions.

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    You could do this:

    Code:
    echo "test" | tee -a file1 file2 > /dev/null
    or this:

    Code:
    echo "test" | tee -a file1 >> file2

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Posts
    15
    Thanks works perfectly!

Posting Permissions

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