The UNIX and Linux Forums  

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 09:50 AM
generating data for 1 hour aajan Shell Programming and Scripting 0 03-17-2008 02:59 AM
help in hour grep ali560045 Shell Programming and Scripting 0 01-31-2008 12:03 AM
how to calculate busy hour shary Shell Programming and Scripting 14 01-29-2008 03:04 AM
an hour less in 24 hour system bobo UNIX for Dummies Questions & Answers 3 10-23-2006 08:55 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-12-2006
Registered User
 

Join Date: Jan 2006
Posts: 145
Unhappy 1 Hour less

set DAY=`date +%y%m%d`
set H=`date +%H`
set M=`date +%M`

mailx -s "$H-Mydata" myemail@mail.com<mydata

I am looking to set the current hour to have 1 hour less in the subject header:

For example: let's say the system time is 8

I want to have "7-Mydata" not "8-Mydata"

Can some1 helps?

Many thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 05-12-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Go into the FAQ and look for datecalc - Perderabo wrote a script to handle time/date arithmetic.
Reply With Quote
  #3  
Old 05-14-2006
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 395
let HOUR=$(date +%H)-1
echo ${HOUR}

Works in korn and bash
Reply With Quote
  #4  
Old 05-14-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Quote:
Originally Posted by System Shock
let HOUR=$(date +%H)-1
echo ${HOUR}

Works in korn and bash
What happens if it is midnight? Would't the HOUR get set to -1?
Reply With Quote
  #5  
Old 05-14-2006
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 395
Quote:
Originally Posted by blowtorch
What happens if it is midnight? Would't the HOUR get set to -1?
Good question
Pesky 00's

if (( $(date +%H) < 1 )); then
HOUR=23
else
let HOUR=$(date +%H)-1
fi
Reply With Quote
  #6  
Old 05-15-2006
Registered User
 

Join Date: Jan 2006
Posts: 145
Unhappy what will the syntax be if I am in:

#!/usr/bin/csh

Thanks!
Reply With Quote
  #7  
Old 05-16-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Something like this probably.
Code:
#!/bin/csh

if( `date +%H` < 1 ) then
        set HOUR=23
else
        set HOUR=`date +%H`
        set HOUR=`expr $HOUR - 1`
endif
echo $HOUR
But this may not be as elegant of efficient as it should be. I'm no csh scripter.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0