add not equal in script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting add not equal in script.
# 1  
Old 02-25-2008
add not equal in script.

Hi, i just want to print the value which are not equal. I try with $str != ${comp2[i]} but still getting same values.


for str in ${comp1[*]}; do
i=0
while (( $i < ${#comp2[*]} )); do
if [[ $str = ${comp2[i]} ]]; then
print value here.
break
fi
(( i += 1 ))
done
done

thanks for you help.
# 2  
Old 02-26-2008
if in case you are trying to compare numeric values, use -ne instead of !=
!= is for string comparison
# 3  
Old 02-26-2008
Hi Yogesh, i tried yesterday also. I have char & numeic value (lg. ge45678).
I got some good result but still getting similar valuses too. is there something diffrent i can try?

Quote:
Originally Posted by Yogesh Sawant
if in case you are trying to compare numeric values, use -ne instead of !=
!= is for string comparison
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Same strings are not equal

Hi there can anyone help me please. I want to make a program to check if the executable file specified by the user exists in the directory. When I run this program particulary these lines of code does not work: if ("$fi" == "$name") then where It checks whether the specified file is equal to the... (1 Reply)
Discussion started by: FUTURE_EINSTEIN
1 Replies

2. Shell Programming and Scripting

If not equal to then loop

How do I go about amending this simple script that prompts for a yes/no response so that if neither Y or N are entered it will loop back back to the original prompt #!/bin/ksh echo "Enter yes of no" read answer if then echo "You selected yes" elif then echo "You selected no" elif... (5 Replies)
Discussion started by: gmears
5 Replies

3. Shell Programming and Scripting

Not equal to in Unix

Guys, I am trying to do below operation LAST_TRANSACTION=2 if ]; then # do something fi If the LAST_TRANSACTION variable is not equal to 1 or 2 or 3 then code inside the if block should be execute. This code is not working, Any help is appreciated. (7 Replies)
Discussion started by: gowrishankar05
7 Replies

4. Shell Programming and Scripting

awk script replace positions if certain positions equal prescribed value

I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX. awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
Discussion started by: halplessProblem
9 Replies

5. Shell Programming and Scripting

awk field equal something, then add something to the field

Hi Everyone, a.txt a b c 1 e e e e e a b c 2 e e e e e the output is a b c 1 e e e e e a 00b c 2 e e e e e when 4th field = '2', then add '00' in the front of 2nd field value. Thanks (9 Replies)
Discussion started by: jimmy_y
9 Replies

6. Shell Programming and Scripting

while [ $x -ge 50 ] + and equal to zero ; then

while + and equal to zero ; then what to punt instead of phrase and equal to zero. it's bash thank you in advance (1 Reply)
Discussion started by: losh
1 Replies

7. Shell Programming and Scripting

equal to operator

Hi, I have the below script executed arg="dir" if "$arg" = "dir" then echo "true" else echo "false" fi Please let me know what happens in the if command. My output is: dir: dir: No such file or directory false which is not the desired output. When i used test command... (1 Reply)
Discussion started by: anijan
1 Replies

8. Shell Programming and Scripting

Bash Script verify user input is not empty and is equal to a value

I need to create a script that has a user enter a value. I want to verify that the value is either 1,2, or 3. If it is not then I want them to try entering it again. I am using a while loop to force them to retry. I am able to test the input against 1,2, and 3, but when I test agains an... (4 Replies)
Discussion started by: spartiati
4 Replies

9. Solaris

Stop+A equal

Hi, I have replaced my current Intel PC machine with Solaris 10, it use to have windows XP. I am sure alot of people already done this and i have seen Solaris running smoothly but having keyboard problem. What is the equal keys in a QWERTY keyboard for selection <Stop+A> ? Is there a... (5 Replies)
Discussion started by: tlee
5 Replies
Login or Register to Ask a Question