LoginSignup
5
5

More than 5 years have passed since last update.

[bash]alias rm='rm -i'やalias rm='mv -i ~/.Trash'を卒業する。

Posted at

alias rm='rm -i'やalias rm='mv -i ~/.Trash'を卒業する。

説明書くの(眠いのd)また今度。スクリプト晒します。

touch ~/rmf
chmod +x ~/rmf
echo "rmf='~/rmf'" >> ~/.bash_profile
vi ~/rmf
  • 下記のスクリプトを貼り付ける
!/bin/bash

if [ ! -e $@ ]; then
    echo "rmf $@: No such file or directory"
    exit 1
fi

echo -n "Delete? [y/N] > "
read INPUT

case "$INPUT" in
   '' | [Yy]* )
       if [ "$@" != / ]; then
          rm -rf $@
       else
          echo "Canceled. (dangerous operation)"
       fi
       ;;
   [Nn]* ) echo "Canceled." ;;
   * ) echo "Canceled." ;;
esac

使用方法

rm -rfの代わりにrmfコマンドを実行

問い合わせは1回だけです!

$ rmf hoge
Delete? [y/N] > y

余談 ルートを消してみる->大丈夫!

$ rmf /
Delete? [y/N] > y
Canceled. (dangerous operation)
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5