の 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
Mac に (GNU バージョンが) インストールされている人coreutils
もいれば、インストールされていない人もいます。先に進む前に、このコマンド ライン フラグを検出する方法はありますか? bash_profile に次のようなものを入れたい:
if [ has_gnu_rm_version ]; then
alias rm="rm -I"
fi