Working with date command

Quick reminder on how to use date command:

    %a – Displays the locale’s abbreviated weekday name.
    %A – Displays the locale’s full weekday name.
    %b – Displays the locale’s abbreviated month name.
    %B – Displays the locale’s full month name.
    %c – Displays the locale’s appropriate date and time representation (default).
    %C – Displays the first 2 digits of the four-digit year as a decimal number (00-99). A year is divided by 100 and truncated to an integer.
    %d – Displays the day of the month as a decimal number (01-31). In a two-digit field, a 0 is used as leading space fill.
    %D – Displays the date in the format equivalent to %m/%d/%y.
    %e – Displays the day of the month as a decimal number (1-31). In a two-digit field, a blank space is used as leading space fill.
    %h – Displays the locale’s abbreviated month name (a synonym for %b).
    %H – Displays the hour (24-hour clock) as a decimal number (00-23).
    %I – Displays the hour (12-hour clock) as a decimal number (01-12).
    %j – Displays the day of year as a decimal number (001-366).
    %k – Displays the 24-hour-clock hour clock as a right-align, space-filled number (0 – 23).
    %m – Displays the month of year as a decimal number (01-12).
    %M – Displays the minutes as a decimal number (00-59).
    %p – Displays the locale’s equivalent of either AM or PM.
    %r – Displays 12-hour clock time (01-12) using the AM-PM notation; in the POSIX locale, it is equivalent to %I:%M:%S %p.
    %S – Displays the seconds as a decimal number (00 – 59).
    %T – Displays the 24-hour clock (00-23) in the format equivalent to HH:MM:SS.
    %w – Displays the weekday as a decimal number in the range 0-6 (Sunday = 0). Refer to the %u field descriptor.

Recent usage example

echo "=== $(hostname).$(date "+%d%b%Y") ===" 

RELATED POST

VirtualBox: Create vm from script

Edit a few variables prior to kicking off the script, for instance the host name in the variable VM='RHEL_6_5_5' to…

System Check before shift begins

Here is an oldie but goodie, right before my shift would begin here is a set of items to check…

Veritas Volume Manager: Growing a disk group and expand the filesystem

Validated by Mr Man! Lets start off on node2 [root@node02 ~]# vxdisk list DEVICE TYPE DISK GROUP STATUS sda auto:none…

Virtual Machine Manager: Error starting domain

Starting up the KVM error occurred Error starting domain: Requested operation is not valid: network 'default' is not active Locate…