Super simple: A collection of shells that output dates

It's simple, but I always forget it, so I'll write it down.

If you want to add today's date and time to the file name when you run the shell and back up the file, remember the following and put it in the shell script so that you do not have to change the date every time.

Format YYYYMMDD

Outputs the Christian era date without partitions.

$(date "+%Y%m%d")

Output example

% echo $(date "+%Y%m%d")
20200316

Format YYYYMMDDHHMMSS

Outputs the time to date and seconds in the Christian era without partitions.

$(date "+%Y%m%d%H%M%S")

Output example

% echo $(date "+%Y%m%d%H%M%S")
20200316122346

Format YYYY / MM / DD-HH: MM: SS

Example with dividers such as slashes and semicolons

$(date "+%Y/%m/%d-%H:%M:%S")

Output example

% echo $(date "+%Y/%m/%d-%H:%M:%S")
2020/03/16-12:24:45

that's all

Recommended Posts

Super simple: A collection of shells that output dates
A simple sample of pivot_table.
[Django] A collection of scripts that are convenient for development
A collection of one-liner web servers
The story of creating a site that lists the release dates of books
Write a super simple TCP server
Pandas: A very simple example of DataFrame.rolling ()
A collection of Numpy, Pandas Tips that are often used in the field
[Python] 3 types of libraries that improve log output a little [logzero, loguru, pyrogrus]
[Complete memorandum] A collection of codes that I often use but cannot remember
A collection of resources that may be useful for creating and expanding dotfiles
A set of integers that satisfies ax + by = 1.
A simple example of how to use ArgumentParser
Display output of a list of floating point numbers
Output in the form of a python array
Simple comparison of Python libraries that operate Excel
Simple code that gives a score of 0.81339 in Kaggle's Titanic: Machine Learning from Disaster