Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



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 !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 05-12-2006
Registered User
 

Join Date: Jan 2006
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
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!
Sponsored Links
  #2  
Old 05-12-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,772
Thanks: 2
Thanked 67 Times in 62 Posts
Go into the FAQ and look for datecalc - Perderabo wrote a script to handle time/date arithmetic.
  #3  
Old 05-14-2006
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 546
Thanks: 0
Thanked 3 Times in 2 Posts
let HOUR=$(date +%H)-1
echo ${HOUR}

Works in korn and bash
  #4  
Old 05-14-2006
blowtorch's Avatar
AFK
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,351
Thanks: 0
Thanked 1 Time in 1 Post
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?
  #5  
Old 05-14-2006
System Shock's Avatar
Registered User
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 546
Thanks: 0
Thanked 3 Times in 2 Posts
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
  #6  
Old 05-15-2006
Registered User
 

Join Date: Jan 2006
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy what will the syntax be if I am in:

#!/usr/bin/csh

Thanks!
  #7  
Old 05-16-2006
blowtorch's Avatar
AFK
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,351
Thanks: 0
Thanked 1 Time in 1 Post
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off


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



All times are GMT -4. The time now is 11:31 PM.