Shell中的变量使用小结
变量的定义,只能以字母和下划线开始,区分大小写,可以包含数字字母下划线.详见官方手册
[root@svnshell_example]#yourname='Linux' [root@svnshell_example]#echo$yourname Linux [root@svnshell_example]#YourName="linux" [root@svnshell_example]#echo"Thevariableis$YourName" Thevariableislinux
获取当前日期的脚本,常用在日志切割中,为了区分每天的日志文件
如下 生成2015年4月27日
[root@svnshell_example]#echo`date+%Y%m%d` 20150427 [root@svnshell_example]#cattoday.sh #!/bin/bash
TODAY=`date+%A` YEAR=`date+%Y年%m月%d日` echo"今天是$YEAR,$TODAY"
[root@svnshell_example]#shtoday.sh 今天是2015年04月27日,星期一