linux 几条好用的bash

1.防止误删除

mkdir -p ~/.trash

alias rm=delete

alias rl='ls -a ~/.trash'

alias ru=undelete

alias rc=cleartrash

delete() {

    mv $@ ~/.trash/

}

undelete() {

   mv -i ~/.trash/$@ ./

}

cleartrash() {

   read -p "clear trash sure?[n]" confirm

  [ $confirm == 'y' ] || [ $confirm == 'Y' ] && sudo /bin/rm -fr ~/.trash/*

}

2.去掉源文件中的注释和空行

alias comtd=comment

comment() {

 mv $@ $@.cmtd

 grep -v "^$" $@.cmtd |

  grep -v "/*" |

  grep -v " **" |

  grep -v "//" >> $@

 rm $@.cmtd

}

原文地址:https://www.cnblogs.com/jesseZh/p/3495011.html