#输出换行符
echo -e "ok\r\n"
#可见expr的优点
smInt=`expr $swapmemory / 1000000`
fileLen=`expr length $filename`
-------------------------------------------------------------------------------------------
#如何取得本机的IP:
auto_get_IP()
{
HOSTNAME=`hostname`
myIp=`grep $HOSTNAME /etc/hosts | grep -v "^#" | head -1 | awk '{print $1}'`
}
head -1 显示第1行 等价于:
head -n 1
-------------------------------------------------------------------------------------------
cat test.sql sqlplus "system/system@lbs" 与 sqlplus "system/system@lbs" @test.sql的区别:
前者执行后自动退出
-------------------------------------------------------------------------------------------
#awk的用法
OS_STD=`cat $CONFIGFILE | grep -w "^OS" | awk -F\= '{print $2}' | grep [^"\ "]`
#管道的用法
[ -d /opt/informix -a -z "$IFX_VERSION" ] && IFX_VERSION=`cat $ids_install \
| grep "IDSVERSION=" | awk -F\= '{print$2}' | awk -F\; '{print$1}'`
-------------------------------------------------------------------------------------------
case "a" in
"a")
echo "ok"
;;
*) #此处注意!
esac
-------------------------------------------------------------------------------------------
#if语句的用法
if [ -n "$DB_STD" ] && [ -n "$DB_STD" -a -z "$DB2_NAME" -a -z "$IFX_NAME" -a -z "$ORA_NAME" ]
then
[ "$DB2_NAME" != "$DB_STD" ] && TMP_DB2_STD=""
fi
-------------------------------------------------------------------------------------------
#grep用法:
#-q:不输出结果,这里我们只利用命令执行的结果返回值:
#对于grep,则搜索到了,就返回0,否则返回1
rpm -qa|grep -qw ssd
if [ $? != 0 ]
then
FLog "Ssd not been installed!" 1
exit 1
fi
-------------------------------------------------------------------------------------------
#!/bin/bash
function testFun
{
index=1
while (($index < 10));do
local temp=$index
echo "temp="$temp
let index+=1 #或index=(index+1)
done
}
testFun