- 论坛徽章:
- 0
|
shell脚本中字符串处理,能精确到字节吗?菜鸟问题,请帮忙
谢谢解答,我参照你的代码写了这样的脚本:
- 1 #! /bin/sh
- 2
- 3 full=`uname -r`
- 4 kernel_version=`uname -r|cut -b -3`
- 5 if [ $kernel_version = 2.6 ]
- 6 then
- 7 echo "kernel version is $full, O.K."
- 8 else
- 9 echo "Error! your Linux kernel version is NOT 2.6, please refer to"
- 10 echo "docs/KERNEL-RECOMPILE and re-compile the kernel"
- 11 exit -1
- 12 fi
- 13 yy_capability=`grep CAPABILITIES /lib/modules/$full/build/.config`
- 14 xx_capability=`echo $yy_capability|cut -b1`
- 15 if [ $xx_capability = '#' ];then
- 16 echo 'CAPABILITIES is not set'
- 17 echo "Error! your Linux kernel NOT compiled with CAPABILITIES=m, please refer to"
- 18 echo "docs/KERNEL-RECOMPILE and re-compile the kernel"
- 19 exit -1
- 20 else
- 21 xx_capability=`echo $yy_capability | cut -d= -f2`
- 22 if[ $xx_capability = 'm' ];then
- 23 echo 'O.K, CAPABILITIES is compiled as a Module.'
- 24 else
- 25 echo 'CAPABILITIES is built-in...'
- 26 echo "Error! your Linux kernel NOT compiled with CAPABILITIES=m, please refer to"
- 27 echo "docs/KERNEL-RECOMPILE and re-compile the kernel"
- 28 exit -1
- 29 fi
- 30 fi
- 31
复制代码
可是运行时出现了:[root@localhost ~]# ./aa.sh
kernel version is 2.6.12, O.K.
./aa.sh: line 22: syntax error near unexpected token `then'
./aa.sh: line 22: ` if[ $xx_capability = 'm' ];then'
这是什么原因呢? |
|