bash:for file in if?
发布时间:2020-12-15 21:09:13 所属栏目:安全 来源:网络整理
导读:所以, for f in *.c; do echo "That $f is the best C code I have ever seen"; done 如果没有c文件,很乐意打印 That *.c is the best C code I have ever seen 这是不可取的.如果没有c文件,是否有一种优雅的方法来修复/表达我想完全跳过循环的事实? 解决方
所以,
for f in *.c; do echo "That $f is the best C code I have ever seen"; done 如果没有c文件,很乐意打印 That *.c is the best C code I have ever seen 这是不可取的.如果没有c文件,是否有一种优雅的方法来修复/表达我想完全跳过循环的事实? 解决方法
设置
nullglob 选项.如果没有匹配,则扩展将为空.
shopt -s nullglob for f in *.c; do … 请注意,这是一个特定于bash的构造,它在普通sh下不起作用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |