To display the current date in Bash, you can use the date
command.
Simply run the following command in a Bash terminal:
date
This will display the current date and time in the default format, which is determined by the system’s locale settings.
If you want to display the date in a specific format, you can use the +
symbol followed by a string of format codes to customize the output. For example, to display the date in the format YYYY-MM-DD
, you can run the following command:
date +'%Y-%m-%d'
This will output the date in the format YYYY-MM-DD
, where YYYY
is the four-digit year, MM
is the two-digit month, and DD
is the two-digit day of the month.
You can find a complete list of format codes in the date
manual page by running man date
in the terminal.