Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash - redirecting of stdoutput and stderror does not catch all output

I am writing some testing scripts and want to catch all error output and write it to an error log as well as all regular output and write that to a separate log. I am using a command of the form

cmd > output.file 2> error.file

The command I am writing test scripts for can cause a segmentation fault. When the command segfaults, bash still prints out segmentation fault to the terminal.

I want this to not happen or get redirected along with standard error.

Is it possible? It must be of bash's doing because both output streams are being redirected.

like image 525
Matt Avatar asked Dec 22 '22 10:12

Matt


1 Answers

bash -c 'cmd >output.file 2>error.file' >bash_output.file 2>&1
like image 121
chaos Avatar answered Jan 13 '23 11:01

chaos