0

I want to get the std output and err out to be written in both files simultaneously by one command

echo $((1/0)) $((1+2)) > out.txt 2> err.txt

it print only the output to the shell not event to the err txt file this command is only an example i want any command to write both file in the same time

Ahmed
  • 1

1 Answers1

0

ok I have found the answer the answer Parentheses is the solution

(echo $((1/0)) $((1+2))) > out.txt 2> err.txt

I think it execute the command and then redirect it but if there is an error it will push the error to the std output but in () brackets the command will execute and the result will be redirected to the file

Ahmed
  • 1