Get the App
SLTechnology News&Howtos  ›  Servers  › 

Create a file at the current time

Shulou Source: shulou.com Published: 2022-06-02 16:03:43 10月04日 Update

View the current time:

[root@master1-192,168117-18] # date "+% y-%m-%d% H:%M:%S"

19-12-17 10:30:44

Create a file at the current time:

[root@master1-192,168117-18] # touch date +% Y%m%d.doc

[root@master1-192,168117-18] # ls-l

Total dosage 8

Drwxr-xr-x 2 root root 4096 December 17 10:21 20191217

-rw-r--r-- 1 root root 0 December 17 10:32 20191217.doc

-rw-. 1 root root 1573 November 7 11:22 anaconda-ks.cfg

Create a folder at the current time:

[root@master1-192,168117-18] # mkdir date +% Y%m%d

[root@master1-192,168117-18] # ls-l

Total dosage 8

Drwxr-xr-x 2 root root 4096 December 17 10:21 20191217

-rw-r--r-- 1 root root 0 December 17 10:32 20191217.doc

-rw-. 1 root root 1573 November 7 11:22 anaconda-ks.cfg

Define a time variable

[root@master1-192,168117-18] # time=date +% Y%m%d

[root@master1-192,168117-18] # echo $time

20191217

[root@master1-192,168117-18] # mkdir $time

[root@master1-192,168117-18] # touch $time.txt

[root@master1-192,168117-18] # ls-l

Total dosage 8

Drwxr-xr-x 2 root root 4096 December 17 11:44 20191217

-rw-r--r-- 1 root root 0 December 17 11:45 20191217.txt

-rw-. 1 root root 1573 November 7 11:22 anaconda-ks.cfg

Tags: Time usage files variables folders Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Shulou Technology Redmi MySQL