Re: storing current month in shell variable..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9:33 Dec 16, 2004 "Mulley, Nikhil" <mnikhil@xxxxxxxxxxxxx> wrote:
> Hi ,
> Nikhil again ... :)
> I wanna store the current month in a shell variable , for which I am
> attempting to do like this ... #!/usr/bin/sh
> MON=`(date | awk '{print $2}')
> echo $MON
> But when I execute the script , I get nothing...
> Can anyone point me in where I have gone wrong ??

The awk stuff is not needed. You can get the month (either numerical or
string) directly from the date command.


# Prints 01-12
monthnum=$(date +%m)
echo $monthnum

# Prints Jan-Dec
monthshort=$(date +%b)
echo $monthshort

# Prints January-December
monthlong=$(date +%B)
echo $monthlong


--Tony

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux