![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|