The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Intel and Wind River driving Linux infotainment systems to cars iBot UNIX and Linux RSS News 0 05-20-2008 04:20 PM
Pleas help..this is driving me crazy hckygoli31 Shell Programming and Scripting 0 05-13-2008 05:59 AM
Test-driving OpenOffice.org 3.0 iBot UNIX and Linux RSS News 0 04-04-2008 12:10 PM
Dumb question but its driving me nuts jepombar UNIX for Dummies Questions & Answers 3 07-03-2007 03:32 PM
unix driving me crazy Tendernisin UNIX for Dummies Questions & Answers 1 11-29-2001 10:38 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-24-2003
alarmcall alarmcall is offline
Registered User
  
 

Join Date: Aug 2003
Posts: 17
Question Simple test driving me mad!

Hi all,

I have been writing a script to automate some work for myself and have come accross a problem. I cannot understand why it doesn't work, but then I am new to both Unix and Korn shell hacking! Here is the problem:

I want to interogate a file for a number and store that number in $tarVal. tarVal is then compared to another number and the appropriate action taken...

What should happen is this. When $success is zero and $tarVal is greater than 0.3 $n should be incremented by 3 and it should then leave the block - agreed? However, for some reason it doesn't! When tarVal has come in at 0.44 (for example) according to the program 0.44 is less than 0.3, so $success has 1 added to it and the newTarVal is set to tarVal (0.44)!!!

Here is the code:

<snip>

tarVal=$(grep 20000 ${truncfile}-${n}-${j}-output.txt | awk {'print $10'})

if [ $success -eq 0 ] && [ $tarVal -gt 0.3 ]; then
n=$((n + 3))
elif [ $success -eq 0 ] && [ $tarVal -le 0.3 ]; then
success=$((success + 1))
newTarVal=$tarVal
elif [ $success -gt 0 ] && [ $tarVal -le $newTarVal ]; then
success=$((success + 1))
newTarVal=$tarVal
else
success=$success
newTarVal=$newTarVal
fi

<snip>

Can ANYBODY enlighten me? I don't know whether I have got syntax wrong (although the script runs without error) or whether the problem lies in the use of the logical AND (&&) in some way? Please, please help as this has been foxing me for hours and hours now and I've tried everything I can think of.

Thanks in advance for any help offered!

alarmcall
 

Bookmarks

Tags
solaris

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 06:06 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