Bash 如何将循环传递给命令perf?
以下命令有效Bash 如何将循环传递给命令perf?,bash,perf,Bash,Perf,以下命令有效 perf stat -I 500 -e cycles sleep 5 while true; do : ; done 但是,此命令会导致语法错误 perf stat -I 500 -e cycles while true; do : ; done bash: syntax error near unexpected token `do' 我试图通过转义来纠正这个问题,但它只会导致另一个错误 $ perf stat -I 500 -e cycles while true\;
perf stat -I 500 -e cycles sleep 5
while true; do : ; done
但是,此命令会导致语法错误
perf stat -I 500 -e cycles while true; do : ; done
bash: syntax error near unexpected token `do'
我试图通过转义来纠正这个问题代码>,但它只会导致另一个错误
$ perf stat -I 500 -e cycles while true\; do : \; done
# time counts unit events
0.005386453 <not counted> cycles
0.005678719 <not counted> cycles
Workload failed: No such file or directory
$perf stat-I 500-e周期为真\;do:\;完成
#时间计数单位事件
0.005386453个周期
0.005678719次循环
工作负载失败:没有这样的文件或目录
将bash循环传递到perf
的正确语法是什么?perf
只能使用参数(execve
语义)运行可执行文件。它本身不调用shell,因此不会运行bash命令
您可以手动调用shell并让它解释您的命令:
perf stat -I 500 -e cycles bash -c 'while true; do true; done'
perf
只能使用参数(execve
语义)运行可执行文件。它本身不调用shell,因此不会运行bash命令
您可以手动调用shell并让它解释您的命令:
perf stat -I 500 -e cycles bash -c 'while true; do true; done'