![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| create filename with 'DD/MM/YYYY' date format | royalibrahim | Shell Programming and Scripting | 4 | 04-12-2008 08:24 AM |
| sed to display date in dd/mm/yyyy format | sars | Shell Programming and Scripting | 2 | 02-15-2007 03:32 AM |
| How can i get the yesterday's date in YYYYMMDD format | prasadsr | HP-UX | 4 | 01-19-2007 09:52 AM |
| convert mmddyy date format to ccyyddd format?? | Bhups | Shell Programming and Scripting | 2 | 09-27-2006 11:30 PM |
| get yesterday date in yyyymmdd format | hk_newbie | UNIX for Dummies Questions & Answers | 2 | 12-14-2001 03:32 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
Using shell script. Code:
#! /bin/ksh
format=YYYYMMDD
YEAR=${format%????}
DAY=${format#??????}
MON=${format#$YEAR}
MON=${MON%$DAY}
echo $MON/$DAY/$YEAR
Code:
echo "YYYYMMDD" | sed -n -e "s_\(....\)\(..\)\(..\)_\2/\3/\1_p" |
|
||||
|
hi all....
Want some clarification .. In the below scripts ... echo "YYYYMMDD" | awk 'BEGIN {OFS="/"}{print substr($1,5,2), substr($1,7,2), substr($1,1,4)}' What is OFS..Also how does the '/' is placed inbetween.. Thanks in advance, Arun.... |
|
||||
|
hi nasirgondal,
I also wanted such a script. It works fine but if the date is not exactly in YYYYMMDD format, lets say YYYYMDD or YYYYMMD format its not working. Is there any solution even for this. Appreciate your help #! /bin/ksh format=YYYYMMDD YEAR=${format%????} DAY=${format#??????} MON=${format#$YEAR} MON=${MON%$DAY} echo $MON/$DAY/$YEAR |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|