![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Distribution Release: Mandriva Linux 2008.1 "Xfce" | iBot | Software Releases - RSS News | 0 | 05-02-2008 06:10 AM |
| sed remove date ex. "Mar 25 2008" | katrvu | Shell Programming and Scripting | 14 | 03-27-2008 12:46 PM |
| Distribution Release: PCLinuxOS 2008 "MiniMe" | iBot | UNIX and Linux RSS News | 0 | 01-07-2008 03:50 PM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
converting date format: "May 31 2008" to "2008-05-31"
I have the following script to find out the last day of the last month .... and the output of this script is in the following format ...
Script goes like this .... #!/bin/ksh cur_month=`date +%m` cur_year=`date +%Y` prev_month=$(($cur_month-1)) # Check to see if this is January if [ $prev_month -lt 1 ] then prev_year=$(($cur_year-1)) prev_month=12 LastDayOfLastMonth=`/bin/cal $prev_month $cur_year | grep -v "^$" | sed -n '1p;$p' | tr "\n" " " | awk '{print substr($1,1,3),$N F,$2}'` else LastDayOfLastMonth=`/bin/cal $prev_month $cur_year | grep -v "^$" | sed -n '1p;$p' | tr "\n" " " | awk '{print substr($1,1,3),$N F,$2}'` fi echo $LastDayOfLastMonth Output will be like this ... May 31 2008 I want this output to be converted to the following format and displayed ... 2008-05-31 -- This is the format i need the output to be Please help me with this .... Thx |
| Bookmarks |
| Tags |
| solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|