How to get 07 while giving ((Preyy = yy - 01))


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get 07 while giving ((Preyy = yy - 01))
# 1  
Old 05-08-2008
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
# 2  
Old 05-08-2008
MySQL Yes i got it...

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  
Old 05-08-2008
Quote:
Originally Posted by RRVARMA
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
Code:
#!/usr/bin/ksh
yy=`date '+%y'`
prev=0$(( yy - 1 ))
echo $prev

# 4  
Old 05-08-2008
Best way to do this

Code:
typeset -R2Z Preyy

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Always giving the answers as 1

Hi, I have wrote a python program to sum the numbers in a list.However its giving answer one. Please advise. MyList = Number = int(input("Please enter number:")) for i in range(1, Number + 1): value = int(input("Enter Numbers %d:" %i)) MyList.append(value) total =... (3 Replies)
Discussion started by: nag_sathi
3 Replies

2. What is on Your Mind?

Happy Thanks Giving

Hello All, I am opening this thread to so that we can THANK ALL moderators/forum advisors/Active users in this forum who really make this place to learn/share/advice :b:. I would like to THANK some people by name too, a very very special THANKS to Neo, Don, Scrutnizer, Corona688, Bartus,... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

3. Shell Programming and Scripting

Script not giving o/p

Hi Below is snippet from script which is not giving the o/p.script name is alarm.sh #!/bin/sh out=`awk '(NR>1) {print $9;exit}' alarm` echo $a however when i simply run the above command i an getting the o/p $ out=`awk '(NR>1) {print $9;exit}' alarm` $ echo $a 6... (2 Replies)
Discussion started by: scriptor
2 Replies

4. Shell Programming and Scripting

Giving Input in a script

Hi, I am a newbie to scripting. I want to know something..Is there any way that I can do this? Here is the thing.. there are so many printer queues in which i need to change a certain option.. am using the hppi utility and i need to modify the printer configuration individually going to each... (3 Replies)
Discussion started by: aksijain
3 Replies

5. UNIX for Dummies Questions & Answers

Kernel 3.0 giving me panic :)

I was very exited to try out new kernel version so i decided to give it a try. http://www.conceivablytech.com/7683/products/linux-torvalds-approves-linux-3-0-rc1 So i downloaded the kernel 3.0-rc1 from The Linux Kernel Archives It was my first kernel compilation everything went smooth... (1 Reply)
Discussion started by: pinga123
1 Replies

6. Shell Programming and Scripting

$0 not giving script name

Why does $0 return the word usage rather than the script name when used in a function? Baffeled on this one, any help appreciated. usage() { echo "$0 -cs <number of batches>\n" echo "$0 -c 4" echo "$0 -s 4" # echo "-c = Create" # echo "-s = Submit\n" exit 1 } $... (1 Reply)
Discussion started by: nhatch
1 Replies

7. UNIX for Dummies Questions & Answers

Last Command not giving year

Hi All, i want the last login details along with year. i tried below command but not giving me the year of last login. last <$Userid> | head -1 i heard that if it is current year then it wont display the year else it will display the year. is it so? if yes then , is there any way of... (1 Reply)
Discussion started by: ani_rvce
1 Replies

8. Shell Programming and Scripting

Last Command not giving year

Hi All, i want the last login details along with year. i tried below command but not giving me the year of last login. last <$Userid> | head -1 i heard that if it is current year then it wont display the year else it will display the year. is it so? if yes then , is there any way of... (1 Reply)
Discussion started by: ani_rvce
1 Replies

9. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies
Login or Register to Ask a Question