这很好(无限循环):
$ while TRUE; do printf ".";done.............................................................................
我正在尝试使用命令实现超时值这个while loop。所有这些都不管用:
$ timeout 5 while TRUE; do printf ".";done
$ timeout 5 "while TRUE; do printf ".";done"
$ timeout 5 "while TRUE; do printf \".\";done"
$ timeout 5 $(while TRUE; do printf ".";done)
$ timeout 5 $('while TRUE; do printf ".";done')什么是正确的方式(如果它存在)?
发布于 2014-12-18 21:17:14
我认为解决问题的方法是执行另一个shell实例并向其传递适当的命令。根据bash手册:
-c If the -c option is present, then commands are read from the first non-option argument command_string.因此,我的解决方案是这样的:
timeout 5 bash -c -- 'while true; do printf ".";done'--确保以下参数将被视为非选项。''帮助传递",而没有不必要的转义。
https://stackoverflow.com/questions/27555727
复制相似问题