|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get the days of Particular date?
Quote:
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for reply I have seen the thread which you have mentioned can you please explain briefly Code:
d="20120103"
day=${d#??????}
temp=${d#????}
month=${temp%??}
year=${d%????}I wont understand what is #??? refer to ? |
|
#4
|
||||
|
||||
|
These are parameter substitution that you can perform in any POSIX shell. Here is the definition from Korn Shell manual: Code:
${parameter#pattern}
${parameter##pattern}
If the shell pattern matches the beginning of
the value of parameter, the value of this
substitution is the value of the parameter
with the matched portion deleted; otherwise
the value of this parameter substituted. In
the former case, the smallest matching
pattern is deleted; in the latter case, the
largest matching pattern is deleted.
${parameter%pattern}
${parameter%%pattern}
If the shell pattern matches the end of the
value of parameter, the value of parameter
with the matched part is deleted; otherwise
substitute the value of parameter. In the
former, the smallest matching pattern is
deleted; in the latter, the largest matching
pattern is deleted.So in day=${d#??????} matches 6 characters from beginning and is deleted. I hope this helps. |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
It might be a good alternative: return 0 for Sunday, 1 for Monday etc. Code:
echo "(6 - $( cal $MM $YY | awk 'NR==3' |wc -w ) + ( $DD % 7 ) ) %7" | bc Last edited by franzpizzo; 02-06-2013 at 04:36 PM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number of days between the current date and user defined date | hiten.r.chauhan | Shell Programming and Scripting | 1 | 03-01-2011 09:13 AM |
| Date after 5 days from current date in YYYYMMDD format | needyourhelp10 | Shell Programming and Scripting | 8 | 09-30-2010 04:33 PM |
| how to get what date was 28 days ago of the current system date IN UNIX | kandi.reddy | Shell Programming and Scripting | 15 | 03-19-2010 12:06 AM |
| date for two days or 3 days ago | tomjones | Shell Programming and Scripting | 7 | 06-02-2009 09:20 AM |
| How to find a date which is 7 days past when given current date | ladtony | Shell Programming and Scripting | 17 | 04-09-2009 04:06 PM |
|
|