|
发表于 2010-4-9 14:47:40
|
显示全部楼层
好脚本。。。我修改如下
.. () {
if [ "$1" = "" ]
then
cd ..
elif expr "$1" : "[1-9][0-9]*$" >/dev/null; then
local arg="$1" s=..
while [ $((--arg)) -gt 0 ]; do
s="$s/.."
done
cd $s
else
local i=$(expr "$PWD" : ".*$1") j
if [ $i -gt 0 ]; then
j=$(expr index "$(expr substr "$PWD" $((++i)) 10000)" /)
[ $j -gt 0 ] && cd "$(expr substr "$PWD" 1 $((i+j)))"
else
echo "ERROR: can't find \"$1\" in \"$PWD\"!" >&2
fi
fi
} |
|