Three must have Aliases in Unix

These three are the must have aliases in your .bashrc file,

#alias rm=’rm -i’ — not useful while deleting directories. It will repetadly prompt for each file.

alias rm=’~/scripts/safe_rm.sh’
alias cp=’cp -i’
alias mv=’mv -i’

safe_rm.sh looks like this,

#!/usr/bin/ksh
YES=yes
CHOICE=no
FILE=$1
FORCE=”

if [[ $1 = '-rf' ]]; then
FILE=$2
FORCE=$1
fi

#if [[ -d $FILE && ! -e $FORCE ]]; then
# FORCE=’-rf’
#fi

echo “rm: remove $FILE (yes/no)?”
read CHOICE

if [[ $CHOICE = $YES ]]; then
echo “rm $FORCE $FILE”
rm $FORCE $FILE
fi

I was late in setting them and had to pay the price today.

Set them before you do an accidental delete or overwrite of important files.

Leave a Comment