!/bin/bash
touch date +%Y%m%d%k%M%S
.txt
touch date +%Y_%m_%d_%k_%M_%S
.txt
touch date +%YY_%mM_%dD_%kH_%MM_%SS
.txt
touch my_date +%YY_%mM_%dD_%kH_%MM_%SS
.txt
测试结果
-rw-r–r– 1 root root 0 4月 7 17:37 2022_04_07_17_37_45.txt
-rw-r–r– 1 root root 0 4月 7 17:37 20220407173745.txt
-rw-r–r– 1 root root 0 4月 7 17:37 2022Y_04M_07D_17H_37M_45S.txt
-rw-r–r– 1 root root 0 4月 7 17:37 my_2022Y_04M_07D_17H_37M_45S.txt
!/bin/bash
mdy=date +%m-%d-%Y
echo “Date in format Month-Date-Year”
echo $mdy
Date in format Month-Date-Year
06-17-2020
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/244895.html