The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to put "grep" in the if condition.. mail2sant Shell Programming and Scripting 1 04-09-2008 02:15 PM
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 12:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 10:52 PM
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 6 11-13-2007 06:00 PM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 01:15 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-30-2007
Registered User
 

Join Date: Dec 2006
Posts: 7
Question IF Condition in ".sh" File (Beginner)

Hi,

I have the below ".sh" file which I just need to put an IF condition to exit from the file/code. Please see the remarks in the code below:

Code:
#!/bin/sh

currentdatehour=`date '+%Y-%m-%d-%H'`

hh=`date '+%H'`
currenthour=`expr ${hh} - 0`
onehourback=`expr ${hh} - 1`
twohoursback=`expr ${hh} - 2`

# Just want to put here an IF condition which should be like this:
# if currenthour = 0 then exit (I don't want to implement the below code if "currenthour" equal to "0")

SCRIPT=$PRODUCTROOT/content/ndobss/ndp777mx.sql
OUTFILE=/m/home/salani/r777_hourly_job/r777_${currentdatehour}_from00.txt

. /m/home/salani/dosql.sh

Thanks in advance...
Reply With Quote
Forum Sponsor
  #2  
Old 05-30-2007
Registered User
 

Join Date: May 2007
Posts: 13
Try this ....

hh=`date '+%H'`
currenthour=`expr ${hh} - 0`
onehourback=`expr ${hh} - 1`
twohoursback=`expr ${hh} - 2`
echo $currenthour
if [ $currenthour -eq 0 ]
then
echo "it is Zero"
exit
echo "i will not print .. Exit... "
else
echo "Non Zero"
fi
Reply With Quote
  #3  
Old 05-30-2007
Registered User
 

Join Date: Dec 2006
Posts: 7
Thanks... it's working now.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:25 AM.


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