![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Giving format to a file | DebianJ | Shell Programming and Scripting | 4 | 03-06-2008 04:08 AM |
| Giving thanks for a long weekend | iBot | UNIX and Linux RSS News | 0 | 12-01-2007 08:05 AM |
| Giving input to a c++ file | tonyaim83 | Shell Programming and Scripting | 2 | 10-22-2007 10:10 PM |
| RLOGIN giving problems. | vishal_ranjan | HP-UX | 8 | 06-28-2007 11:47 AM |
| Giving others execute privileges | FredSmith | UNIX for Dummies Questions & Answers | 10 | 01-26-2006 07:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
How to get 07 while giving ((Preyy = yy - 01))
Hi,
I need to get the previous year as 07 instead of just 7. I'm running the following for this.. yy=`date '+%y'` ((Preyy = yy - 01)) echo ${Preyy} Here, instead of 07 i'm getting 7 as result. Please Help. Thanks, RRVARMA |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
i just added this in between...
Preyy=$(printf "%02d" $Preyy) and now my script goes lik this.. yy=`date '+%y'` ((Preyy = yy - 01)) Preyy=$(printf "%02d" $Preyy) echo ${Preyy} Thanks, RRVARMA |
|
#3
|
|||
|
|||
|
Quote:
Code:
#!/usr/bin/ksh yy=`date '+%y'` prev=0$(( yy - 1 )) echo $prev |
|
#4
|
|||
|
|||
|
Best way to do this
Code:
typeset -R2Z Preyy |
|||
| Google The UNIX and Linux Forums |