这里是我的代码字符串操作
real_path="/u1/h7/user/469/code/hw4/b.sh"
while [ "$real_path" != "/" ]
do
echo $real_path
real_path=${real_path%/*}
done
echo $real_path #just to print the root '/'
,我想我的剧本打印以下行,但似乎real_path=${real_path%/*}
没有工作,任何建议或实现这个其他的方式?
/u1/h7/user/469/code/hw4/b.sh
/u1/h7/user/469/code/hw4
/u1/h7/user/469/code
/u1/h7/user/469
/u1/h7/user
/u1/h7
/u1
/
的感谢!我没在想!无论如何,你建议我怎么可以上一个目录? – 2015-02-11 19:28:38
我的脚本不适合你吗? – anubhava 2015-02-11 19:29:45
我想我的最后一个输出是u1的父目录,它是根。非空.... – 2015-02-11 19:32:01