How to redirect the output to two different files when two command are involved simultaneously?

StackOverflow https://stackoverflow.com/questions/13232889

  •  27-11-2021
  •  | 
  •  

Pergunta

I am using perf tool to analyze sort utility . I gave following command.

perf stat -x, ../bin/sort data >/dev/null 2>perf_data

I want to redirect the output of sort to /dev/null and output of perf to perf_data file.

How can I Do this ?

Foi útil?

Solução

Actually you can put it in parenthesis. Following command has worked for me.

(perf stat -x, ../bin/sort data >/dev/null) 2>perfoutput.txt

Outras dicas

The "perf" command has an option to redirect output to a file directly using -o option. In your case this will be

perf stat -o perfoutput.dat -x, ../bin/sort data >/dev/null

Depending on the way how perf runs the program, simply quoting the arguments may be enough:

perf stat -x, '../bin/sort data >/dev/null' 2>perf_data
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top