私が作業しているロギングスクリプトのperf stat出力から 'seconds time elapsed'出力を含む行を抽出したいとします。端末のコマンド出力から1行を抽出する
ファイルに出力を書き込んだり、ファイルを検索したりしたくありません。私はgrepやそれに類するものを使ってやりたいと思います。私は
grep: seconds time elapsed: No such file or directory
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
echo: Broken pipe
Performance counter stats for 'echo Sample_String' (10 runs):
0.254533 task-clock (msec) # 0.556 CPUs utilized (+- 0.98%)
0 context-switches # 0.000 K/sec
0 cpu-migrations # 0.000 K/sec
56 page-faults # 0.220 M/sec (+- 0.53%)
<not supported> cycles
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not supported> instructions
<not supported> branches
<not supported> branch-misses
0.000457686 seconds time elapsed (+- 1.08%)
を取得し、私は私が
Performance counter stats for 'echo Sample_String -eE seconds time elapsed' (10 runs):
0.262585 task-clock (msec) # 0.576 CPUs utilized (+- 1.11%)
0 context-switches # 0.000 K/sec
0 cpu-migrations # 0.000 K/sec
56 page-faults # 0.214 M/sec (+- 0.36%)
<not supported> cycles
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not supported> instructions
<not supported> branches
<not supported> branch-misses
0.000456035 seconds time elapsed (+- 1.05%)
012を持っているため、この
perf stat -r 10 echo "Sample_String" > grep -eE "seconds time elapsed"
を試してみました
perf stat -r 10 echo "Sample_String" | grep -eE "seconds time elapsed"
れる:ここで
は、私が試したものです
grep、awk、sedのような新しいツールです。私は誰かが私を助けることを願っています。また、ファイルに出力を書き込んだり、ファイルを検索したりしたくない場合もあります。
それは働いた、ありがとうございます。 '2>&1'は何を意味し、それは何を意味しますか? –
stderrをstdoutにリダイレクトします。詳細については、この記事を参照してください:http://stackoverflow.com/a/2342841/2679935 – julienc