linux shell 中 如何处理空格的路径?
有目录如下:[root@iZ94611itifZtest]#find.-typed./ab#注中间有空格./ac有一个test.sh脚本如下:[root@iZ94611i...
有目录如下:
[root@iZ94611itifZ test]# find . -type d
./a b #注中间 有空格
./a c
有一个test.sh 脚本如下:
[root@iZ94611itifZ test]# cat test.sh
#/bin/bash
myhome=`pwd`
for str in `find . -type d`
do
cd "$str"
echo "process $str"
cd $myhome
done
运行 [root@iZ94611itifZ test]# sh test.sh
process .
test.sh: line 10: cd: ./a: No such file or directory
process ./a
test.sh: line 10: cd: b: No such file or directory
process b
test.sh: line 10: cd: ./a: No such file or directory
process ./a
test.sh: line 10: cd: c: No such file or directory
process c
linux shell 中 如何处理空格的路径? 展开
[root@iZ94611itifZ test]# find . -type d
./a b #注中间 有空格
./a c
有一个test.sh 脚本如下:
[root@iZ94611itifZ test]# cat test.sh
#/bin/bash
myhome=`pwd`
for str in `find . -type d`
do
cd "$str"
echo "process $str"
cd $myhome
done
运行 [root@iZ94611itifZ test]# sh test.sh
process .
test.sh: line 10: cd: ./a: No such file or directory
process ./a
test.sh: line 10: cd: b: No such file or directory
process b
test.sh: line 10: cd: ./a: No such file or directory
process ./a
test.sh: line 10: cd: c: No such file or directory
process c
linux shell 中 如何处理空格的路径? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询