/home/jem/rep_0[1-3]/logs/SystemOut.log bash: /home/jem/rep_0[1-3]/l...">

Ambiguous redirection when redirecting to multiple files using Bash

$ echo "" > /home/jem/rep_0[1-3]/logs/SystemOut.log bash: /home/jem/rep_0[1-3]/logs/SystemOut.log: ambiguous redirect 

Can I redirect multiple files at the same time?

Edit: Any answer that allows you to use an ambiguous file link?

+9
source share
6 answers

What it is intended for:

 command | tee file1 file2 file3 > file4 

tee also outputs to stdout, so you can either put one file after the redirect (as shown above) or send stdout to /dev/null .

In your case:

 echo "" | tee /home/jem/rep_0[1-3]/logs/SystemOut.log >/dev/null 
+21
source

You can do this using tee , which reads from stdin and writes to stdout and files. Since tee also outputs to stdout, I decided to direct it to /dev/null . Please note that the bash extension matches existing files, so the files you are trying to write must exist before this command is executed for it to work.

 $ echo "" | tee /home/jem/rep_0[1-3]/logs/SystemOut.log > /dev/null 

As a side note, the "" that you switch to echo is redundant.

Not directly relevant to your question, but if you are not relying on the bash extension, you can have multiple channels.

 $ echo hello > foo > bar > baz $ cat foo bar baz hello hello hello 
+5
source

I had the same question, and I just wanted to add an example with a wildcard, as it was not shown. I think this is what you were looking for:

 echo "" | tee *.log 
+3
source

You can do it:

 echo "" | tee /home/jem/rep_0{1..3}/logs/SystemOut.log 

To suppress the output on stdout, add this to the end of the above commands:

 > /dev/null 

The echo command in your question (which does not require empty quotes) simply puts a new line in the lines. If you want to create empty files, use the touch command.

+1
source

Not. How about using tee twice?

 echo "Your text" | tee file1 | tee file2 > file3 
0
source

Pipe to the tee command to go to the file and fail, cascade of tee commands

0
source

All Articles