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

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

  •  27-11-2021
  •  | 
  •  

문제

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 ?

도움이 되었습니까?

해결책

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

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top