首先, Shell赋值时,等号左右两边是不能有空格的
一般赋值
-
s=123
-
echo $s
日期赋值
-
s=`date +"%Y-%m-%d"` # 注意`不是单引号, 而是~下面的点
-
echo %s`
对字符串进行连接
-
str1=abc
-
str3=${str1}.gz
-
echo $str3
Shell 命令中的日期的相关参数
-
%%
-
a literal %
-
%a
-
locale's abbreviated weekday name (e.g., Sun)
-
%A
-
locale's full weekday name (e.g., Sunday)
-
%b
-
locale's abbreviated month name (e.g., Jan)
-
%B
-
locale's full month name (e.g., January)
-
%c
-
locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
-
%C
-
century; like %Y, except omit last two digits (e.g., 21)
-
%d
-
day of month (e.g, 01)
-
%D