Create File or Directory with Date Time
Q. How do I create directory with current date and time? Write a shell script, which will create directories with the current date and time.
Example
Create a directory based on current date.
1 2 3 4 5 6 7 | #!/bin/bash NAME=`date +%d%b%Y` touch ${NAME}.txt mkdir ${NAME} |
The above script will create a file with current date and .txt extension like 28Oct2020.txt
. And also create a directory with current date like 28Oct2020
.
Here is more combinations of date and time to create directory. Use this with “date +” command.
1 | %d%b%Y | 28Oct2020 |
2 | %b%d%Y | Oct282020 |
2 | %Y%b%d | 2020Oct28 |