Loading

Shell 脚本

$( CMD ) 将会执行 CMD, 然后用 CMD 的输出作为整体的值. 例如:

for file in $(ls)

会遍历当前目录的文件

[[]] 进行比较:

if [[ $? -ne 0 ]]; then
    echo "File $file does not have any foobar, adding one"
    echo "# foobar" >> "$file"
fi

通配符:

? 匹配任意一个字符

* 匹配任意个字符

{} 可以自动展开, 比如:

convert image.{png,jpg}
# will expand to
convert image.png image.jpg
# Show differences between files in foo and bar
diff <(ls foo) <(ls bar)
posted @ 2025-12-25 22:11  Chase_Tsai  阅读(1)  评论(0)    收藏  举报