Skip to content

Commit 3df60d1

Browse files
ZhuangZhu-74jaywcjlove
authored andcommitted
Update date.md (jaywcjlove#107)
为date命令添加用法
1 parent 28d0fa3 commit 3df60d1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

command/date.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,19 @@ difference=$(( end - start ))
152152
echo $difference seconds.
153153
```
154154

155+
当你考虑输出带有时间的字符串时,例如(Current time: 2019/05/19):
156+
157+
最常用的方法:
158+
159+
```shell
160+
echo -e "Current time: $(date +"%Y%m%d")"
161+
```
162+
163+
另一种方法:
164+
```shell
165+
suffix='Current time:'
166+
#和echo的用法差不多,注意如果换成单引号就不能替换变量了。
167+
date +"${suffix} %Y/%m/%d"
168+
```
155169

156170
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->

0 commit comments

Comments
 (0)