String math help needed

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String math help needed
# 1  
Old 09-28-2007
String math help needed

#`rm $DAT1` 
#`rm $DAT2` 
`bdf | grep /var/opt/ixos | awk '{ print $4 }' | cut -f1 -d"%" > test.dat` `bdf | grep /var/opt/ixos | awk '{ print $5 }' > test2.dat` 
set -A PERCENTAGES `cat test.dat` 
set -A MOUNTPOINTS `cat test2.dat`  
while [ $i -lt $len ] do         
     if ( $value > $THRESHOLD ) then
                    echo "${MOUNTPOINTS[$i]} IS ${PERCENTAGES[$i]}% FULL RIGHT NOW....please increase the space soon."         
     (( i=i+1 )) 
exit 0

The above is working just fine for me except that the $value > $THRESHOLD comparison fails. PERCENTAGES is simply an array of numbers (actually strings) that I want to cue off of and only write a line to a log file if the value is above whatever THRESHOLD is set to. Sounds easy enough but apparently shell script math and I don't get along.

Any help is appreciated.
# 2  
Old 09-29-2007
Try to substitute this:

if ( $value > $THRESHOLD ) then

with this:

if [ $value -gt $THRESHOLD ] then

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk evaluating a string as a math expression

Hi, I am writing a script in awk trying to replace strings that are math expressions with their result. For example, I have a file that looks like this: 5-1 32/8-1 4*12 17+1-3 I would like to get the following output: 4 3 48 15 I tried doing it the following way (using the "bc"... (8 Replies)
Discussion started by: avi.levi
8 Replies

2. Shell Programming and Scripting

Help Needed! - Cut characters after a text string and append to end of filename

Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename. for example: I have file 111_123 that contains ACCOUNT:ABC1234567 The file... (5 Replies)
Discussion started by: cinderella1
5 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Help needed to have changing value to the command prompt string variable PS1

Hi, I am using git bash terminal window to do git operations. I have set the prompt string variable PS1 in the ~/.bashrc file as follows: export PS1=" " This is intended to show me the current git branch's name which is active as part of the prompt string. But, the problem is when I do a git... (2 Replies)
Discussion started by: royalibrahim
2 Replies

4. Shell Programming and Scripting

Urgent help needed !!! replace a exact string

Hi experts, As i am a novice unix need help for the below query...banged my head from quite a while...:confused: i have a set of html files, in which i need to search for string "Page"(case sensitive) and then replace the same with some numeric code ,say, "XXX1234". Here in... (1 Reply)
Discussion started by: rahulfhp
1 Replies

5. Shell Programming and Scripting

Help needed to remove a char from a specified sub-string

Hi! I'm having trouble usind sed to remove the char ' from within a database's varchar register's sql. For example, on the following sql: INSERT INTO patrimonio_municipal.patrimonio_municipal_airc_tmp Values('|Estação Elevatória|',|16723|,'|Grandes Reparações|', '|2010-03-26... (3 Replies)
Discussion started by: cremat0rio
3 Replies

6. Shell Programming and Scripting

Printing 10 lines above and below the search string: help needed

Hi, The below code will search a particular string(say false in this case) and return me 10 lines above and below the search string in a file. " awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print("***********************************");print;c=a;}b{r=$ 0}' b=10 a=10 s="false" " ... (5 Replies)
Discussion started by: vimalm22
5 Replies

7. Shell Programming and Scripting

Help needed passing string to command

hi to all code: </div> command... "command_name arg1 arg2 option=xxxxx" example --- useradd username group=xxxxxx. </div> when someone ran this command it point to some other script (say script1), mean post execution of command. in the script1 i need only "xxxxx" value. then i... (5 Replies)
Discussion started by: honeym210
5 Replies

8. UNIX for Dummies Questions & Answers

Help needed in search string

Hi , I learning shell scripting.. I need to do the following in my shell script. Search a given logfile for two\more strings. If the the two strings are found. write it to a outputfile if only one of the string is found, write the found string in one output file and other in other... (2 Replies)
Discussion started by: amitrajvarma
2 Replies

9. Shell Programming and Scripting

Help needed in string manipulation

Hi, Im a newbie to UNIX Shell Scripting. I have a variable "filename" which contains the value "fileone.out". I need help in doing some string manipulation on this variable to change the extension alone and the result should be "fileone.txt", since i need to use this new value to refer another... (4 Replies)
Discussion started by: haifrancis
4 Replies

10. Shell Programming and Scripting

Help needed in String manipulation

Hi, How to find existance of a string inside another string in unix scripting? Can you give me with an example. I tried this, awk 'BEGIN { print index("peanut", "an") }' But when I used this example, the command prompt was not returning. Only I had to forcibly end by using ^C. Any... (2 Replies)
Discussion started by: ramanan
2 Replies
Login or Register to Ask a Question