$ 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 to multiple files at a time?
Edit: Any answer that allows use of the ambiguous file reference?
That's what tee is for:
command | tee file1 file2 file3 > file4
tee also outputs to stdout, so you may want either to put one file after a redirect (as shown above), or send stdout to /dev/null
.
For your case:
echo "" | tee /home/jem/rep_0[1-3]/logs/SystemOut.log >/dev/null
You can do this using tee
, which reads from stdin and writes to stdout and files. Since tee
also outputs to stdout, I've chosen to direct it's output to /dev/null
. Note that bash expansion matches against the existing files, so the files you're trying to write to must exist before executing this command for it to work.
$ echo "" | tee /home/jem/rep_0[1-3]/logs/SystemOut.log > /dev/null
As a side note, the ""
you pass to echo
is redundant.
Not directly relevant to your question, but if you don't rely on bash expansion you can have multiple pipes.
$ echo hello > foo > bar > baz
$ cat foo bar baz
hello
hello
hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With