|

楼主 |
发表于 2008-1-9 15:02:47
|
显示全部楼层
...还有个小问题:
我将前辈们提供的方法在终端运行没有问题,可写到脚本里怎么会报错?我是这样写的:
-------------------
#!/bin/bash
DIR=`pwd`
name=${DIR##*/}
AB=(${name/-/})
A=${a[0]}
B=${a[1]}
-------------------------
报错:./test: line 30: ${DIR ##*/}: bad substitution
啥原因哦?
在终端运行正常:
leon@LSGI:~/test/20070216-20060630> DIR=`pwd`
leon@LSGI:~/test/20070216-20060630> name=${DIR##*/}
leon@LSGI:~/test/20070216-20060630> AB=(${name/-/})
leon@LSGI:~/test/20070216-20060630> A=${AB[0]}
leon@LSGI:~/test/20070216-20060630> B=${AB[1]}
leon@LSGI:~/test/20070216-20060630> echo $name $A $B
20070216-20060630 20070216 20060630 |
|