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

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

Join Date: Jan 2006
Posts: 148
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!
  #2 (permalink)  
Old 05-12-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
Go into the FAQ and look for datecalc - Perderabo wrote a script to handle time/date arithmetic.
  #3 (permalink)  
Old 05-14-2006
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

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

Works in korn and bash
  #4 (permalink)  
Old 05-14-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 05-14-2006
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
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 (permalink)  
Old 05-15-2006
bobo bobo is offline
Registered User
  
 

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

#!/usr/bin/csh

Thanks!
  #7 (permalink)  
Old 05-16-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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

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 03:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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