1.清空log文件
: >log.txt
等同于
cat /dev/null > log.txt
2. 脚本注释、占位符
在编写脚本的过程中,某些语法结构需要多个部分组成,但开始阶段并没有想好或完成相应的代码,这时就可以用:来做占位符,否则执行时就会报错。
#!/bin/bash
var=0
if [ "$var" = "0" ]; then
:
else
:
fi
==============
3. 等同于true , while :就是while true
#!/bin/bash
while :
do
echo "dead loop..."
done
=====================
if [ "today" == "2011-08-29" ]; then
:
else
:
fi
(netstat -lntup | grep -w 25| awk -F "[ :]+" 'NR==1{print $5}') = 25
====================
今天在群里面有人问到:ifconfig eth0|awk -F "[ :]+" 'NR==2{print $4 "/" $NF}',我执行了一下
: >log.txt
等同于
cat /dev/null > log.txt
2. 脚本注释、占位符
在编写脚本的过程中,某些语法结构需要多个部分组成,但开始阶段并没有想好或完成相应的代码,这时就可以用:来做占位符,否则执行时就会报错。
#!/bin/bash
var=0
if [ "$var" = "0" ]; then
:
else
:
fi
==============
- #!/bin/sh
- : this is single line comment
- : 'this is a multiline comment,
- second line
- end of comments'
- if [ "1" == "1" ]; then
- echo "yes"
- else
- :
- fi
3. 等同于true , while :就是while true
#!/bin/bash
while :
do
echo "dead loop..."
done
=====================
if [ "today" == "2011-08-29" ]; then
:
else
:
fi
(netstat -lntup | grep -w 25| awk -F "[ :]+" 'NR==1{print $5}') = 25
====================
今天在群里面有人问到:ifconfig eth0|awk -F "[ :]+" 'NR==2{print $4 "/" $NF}',我执行了一下