Blog:博客园 个人 译自BashPitfalls 本文总结了编写Shell脚本中的常见错误. for f in $(ls *.mp3) 最常犯的错之一就是编写这样的循环: for f in $(ls *.mp3); do # Wrong! some command $f # Wrong! done for f in $(ls) # Wrong! for f in `ls` # Wrong! for f in $(find . -type f) # Wrong! for f in `find…
if-then if command then command fi if-then-else if command then command else command fi 嵌套if if command then command elif command then command elif command then command else command fi 复合条件测试 [ condition1 ] && [ condition2 ] 两者同时满足 [ condition1 ]…