1 #!/bin/bash
2 #copy the /usr/bin directory listing to a log file
3
4 #命令替换:从命令输出中提取信息并将其赋给变量————有两种方法:
5 #反引号(`)
6 #$()格式
7
8 today=$(date +%y%m%d)
9 ls /usr/bin -al > log.$today
10 echo $today
运行结果:
1 #!/bin/bash
2 #copy the /usr/bin directory listing to a log file
3
4 #命令替换:从命令输出中提取信息并将其赋给变量————有两种方法:
5 #反引号(`)
6 #$()格式
7
8 today=$(date +%y%m%d)
9 ls /usr/bin -al > log.$today
10 echo $today
运行结果: