linux-101-hacks

Linux 101 hacks 翻译

”There are only 10 types of people in the world — those who understand binary, those who don’t, and those who understand gray code” — Geek

Author:Ramesh Natarajan 译者:wrfly From:www.thegeekstuff.com

  • CDPATH
$ pwd
/tmp
$ cd mail
-bash: cd: mail: No such file or directory
[木有这个目录]
$ export CDPATH=/etc # 或者直接 CDPATH=/etc
$ cd mail
/etc/mail
[进去了!!!]
$ pwd
/etc/mail

ps:CDPATH支持多个目录变量,比如,你可以CDPATH=$CDPATH:/home:/var/www:/etc:/opt,然后就可以切换到任意其中一个目录的子目录下,相当可爱~

  • 返回上上上上层目录
alias ..="cd .."
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."

或者

alias cd1="cd .."
alias cd2="cd ../.."
alias cd3="cd ../../.."
alias cd4="cd ../../../.."
alias cd5="cd ../../../../.."

挺有趣的。

  • mcd 把下面的function添加到 .bash_aliases中。
function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
  • cd - 返回到上次的目录,相当于后退。

  • popd pushd dirs 这三条命令相当有趣,其中pushd dir_1是:1.把dir_1这个文件夹push到dir的队列中;2.进入dir_1;3.显示当前的dir队列。 而popd则是从dir的队列中跳出来,

…… 好久没翻译了……有点羞愧呢…… 目前翻译转移到了 gitbook 2015-12-20

comments powered by Disqus