1. Home
  2. Bash
  3. Examples
  4. Bash – Create File Directory with Datetime

Bash – Create File Directory with Datetime

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.

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%Y28Oct2020
2%b%d%YOct282020
2%Y%b%d2020Oct28