Update date.md (#107)

为date命令添加用法
This commit is contained in:
ZhuangZhu-74 2019-05-19 10:13:25 +08:00 committed by 小弟调调™
parent 28d0fa37e2
commit 3df60d19ec
1 changed files with 14 additions and 0 deletions

View File

@ -152,5 +152,19 @@ difference=$(( end - start ))
echo $difference seconds. echo $difference seconds.
``` ```
当你考虑输出带有时间的字符串时例如Current time: 2019/05/19
最常用的方法:
```shell
echo -e "Current time: $(date +"%Y%m%d")"
```
另一种方法:
```shell
suffix='Current time:'
#和echo的用法差不多,注意如果换成单引号就不能替换变量了。
date +"${suffix} %Y/%m/%d"
```
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ --> <!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->