GNU 版本rm
有一个很酷的 -I 标志。从手册页:
-I prompt once before removing more than three files, or when removing recursively. Less
intrusive than -i, while still giving protection against most mistakes
Mac 不会:
$ rm -I scratch
rm: illegal option -- I
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
有时人们coreutils
在 Mac 上安装了(GNU 版本),有时却没有。有没有办法在继续之前检测到这个命令行标志?我想在我的 bash_profile 中有这样的东西:
if [ has_gnu_rm_version ]; then
alias rm="rm -I"
fi