Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Last updated: Jul 08, 2022

How to use a date shell script

Here you will find out:

  • what a bash date command is
  • how to format the bash date and how to use these scripts
  • when DiskInternals can help you

Are you ready? Let's read!

What is a bash date command?

Simply put, this is a command used to print the current system date and time. Also, it can be used to set the date and time on a Linux system. The bash date command is among the core Linux utilities, and it prints the date and time zone when a Unix/Linux system is configured.

The current date and time

If you run the bash date command without including a variable, the result will look like what you see below:

Run the bash date commandRun bash date command

How to format the bash date

There are different ways to format the output of a bash date command.

To get date and time in U.S. format (MM/DD/YY HH:MM:SS), use the code below:

Date and time in U.S. format

Output:

Output

If you want to get the date and time in a different format (e.g., YYYY-MM-DD HH:MM:SS):

The date and time in a different format

How to use these scripts

The easiest way to learn how to run bash date scripts is to run date --help to print the help information.

The following describes the bash date options:


Format optionOutput
%aAbbreviated weekday name (e.g., Mon)
%AFull weekday name (e.g., Monday)
%bAbbreviated month name (e.g., Aug)
%BFull month name (e.g., August)
%cAbbreviated local date and time (e.g., Mon Jan 5 24:20:54 2019)
%FFull date in this format: %Y-%m-%d
%sSeconds
%uDay of the week (1-7), where 1 represents Monday, 2 is Tuesday, etc.
%UWeek number of the year (00-53), where Sunday is treated as the first day of the week

Examples of using a bash date script

For all these examples, take note of the capital and small letters, because “M” and “m” do not mean the same thing.

Get date in MM-YYYY

Get date in MM-YYYY

Get date and time in MM/DD/YY HH:MM:SS

Get date and time in MM/DD/YY HH:MM:SS

Get date in MM-DD-YYYY

Get date in MM-DD-YYYY

Get time on Unix epoch format

Get time on Unix epoch format

Get date and time in YYYY-MM-DD HH:MM:SS

Get date and time in YYYY-MM-DD HH:MM:SS

How to open Linux files in Windows easily

If you have ever worried about accessing Linux files in Windows, here’s an ideal solution for you. DiskInternals Linux Reader is an advanced PC utility that is available for free. It comes with a bunch of handy features for accessing and viewing Linux files in Windows computers. Also, DiskInternals Linux Reader works for virtual machines. The most interesting part of this utility is that it doesn't support any algorithm. It is intuitive to use, and supports various file systems and previews any type of file (pictures, videos, documents, etc.).

Related articles

FREE DOWNLOADVer 4.22, WinUpgrade to PROFrom $29.95

Please rate this article.
52 reviews