每日一收获 cd `dirname $0` $0 代表的是你执行的脚本!若是在命令行下的 因为你执行的是 bash 而 bash 在/bin 目录下 ,dirname就是得到$0的目录下。所以在命令行下得到的结果就是/bin
若是在脚本中,那么就是 $0 代表的是写的脚本 ,比如说脚本a.shell 在 dirname $0 < ===== > dirname a.shell . man dirname下
Print NAME with its trailing /component removed; if NAME contains no /'s, output `.' (meaning the current directory).
我们可以知道得到是脚本当前的路径,就是 (.)符号
用途:这个脚本的作用在于获取系统的相对路径,然后跳转到其他目录下!
哈哈,谁知道下面这个脚本是干什么的呢,猜中有奖!
find . -type f |grep java$|xargs du -h |sed -e 's/K//g' |awk 'BEGIN{maxsize=0;filename=temp}$1>maxsize{maxsize=$1;filename=$2}END{printf "%s\t%s\n",maxsize,filename}'