The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
Finding mail per hour Prince2 Shell Programming and Scripting 2 05-22-2008 12:50 PM
help in hour grep ali560045 Shell Programming and Scripting 0 01-31-2008 03:03 AM
AIX 5.3 12 Hour System Clock RTwitchell AIX 2 04-10-2007 04:02 PM
1 Hour less bobo UNIX for Dummies Questions & Answers 6 05-16-2006 12:07 PM
record wc -l over 24 hour period csaunders Shell Programming and Scripting 5 12-09-2005 02:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
Unhappy an hour less in 24 hour system

My program:

__________________________________

#!/bin/ksh

DAY=`date +%y%m%d`
H=`date +%H`
M=`date +%M`
day=`date +%m/%d/%y`
let h=$H-1
echo DAY $DAY
echo H $H
echo M $M
echo day $day
echo h $h

_____________________________________

My result:

______________________________________

DAY 061023
H 09
M 38
day 10/23/06
h 8

_______________________________________


My need help:


on the "let h=$H-1" I have the result of number 8; how can I make it 08 ( have the zero in front of 8)


please help
  #2 (permalink)  
Old 10-23-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
use typeset

Just declare 'h' using
Code:
typeset -Z2 h
And then do your calculations. Also check this post for more details - typeset
  #3 (permalink)  
Old 10-23-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
printf "%02d" $h
  #4 (permalink)  
Old 10-23-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,932
just for inf purpose only

if [ $h -lt 10 ]
then
h=0$h
fi
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0