05-17-2013
Your comparison is always true, no matter what $tabla's contents be: if it's "KKKKKK", then the second term is true, else the first.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi,
I need to create an IF condition. I read a line from a file and get the 5 word using space as a delimited. This word can have only two values either '*' or '1-5'
I need to write an IF condition for two cases. I can either compare it to * or 1-5(or even 1 by cutting and getting only the... (3 Replies)
Discussion started by: kaushys
3 Replies
2. Shell Programming and Scripting
Hi,
I am trying to write a script to show the status of a Network card.
Variables:
chosennic is a read variable
statuss=`/sbin/ifconfig $chosennic | grep MTU | awk '{print $1}'`
ipadd=`/sbin/ifconfig $chosennic | grep Bcast | awk '{print $2}' | awk -F : '{print $2}'`... (2 Replies)
Discussion started by: mikejreading
2 Replies
3. Programming
Hello,
I need help with a program I'm trying to write for my moms science class, what it has to do is accept a user inputed string and search for it in a text file (file contains all the elements)
The file looks like:
H Hydrogen 1
He Helium 2
Li Lithium 3
Be Beryllium 4
...
If the... (1 Reply)
Discussion started by: duvalC
1 Replies
4. Programming
Hello,
I need help with a program I'm trying to write for my moms science class, what it has to do is accept a user inputed string and search for it in a text file (file contains all the elements)
The file looks like:
H Hydrogen 1
He Helium 2
Li Lithium 3
Be Beryllium 4
...
If the... (0 Replies)
Discussion started by: duvalC
0 Replies
5. Shell Programming and Scripting
Hi Champs,
I am a newbie to unix world, and I am trying to built a script which seems to be far tough to be done alone by me.....
" I am having a raw csv file which contains around 50 fields..."
From that file I have to grep 2 fields "A" and "B"....field "A" is to be aligned vertically... (11 Replies)
Discussion started by: jitendra.pat04
11 Replies
6. Shell Programming and Scripting
I have a file
$ cat myfile
A 02/16/2012
B 02/19/2012
C 02/20/2012
D 02/17/2012
E 02/16/2012
My simple script
> cat myscript.sh
mydate="02/16/2012"
awk ' ($2~/$mydate/) {print $1}' < myfile
but I got no output! and when I try $2~/'$mydate'/
I got: The error context is (2 Replies)
Discussion started by: Sara_84
2 Replies
7. UNIX for Dummies Questions & Answers
Hi All,
I am trying to to compare a string variable with a string literal inside a loop but keep getting the
./testifstructure.sh: line 6:
#!/bin/sh
BOOK_LIST="BOOK1 BOOK2"
for BOOK in ${BOOK_LIST}
do
if
then echo '1'
else
echo '2'
fi
done
Please use next... (1 Reply)
Discussion started by: daveu7
1 Replies
8. Shell Programming and Scripting
Is this possible? If so it seems like a very easy and short script.I'd like to make a script that will print a friendly message but only if it is on your personal terminal. so the code would look like this:
#!/bin/csh
if ;
then
echo "This is a friendly message :D ";
fi
thats what i have... (4 Replies)
Discussion started by: Waffles
4 Replies
9. Shell Programming and Scripting
Hi ,
I have one file like
BUD,BDL BUDCAR
BUD,BDL BUDLAMP
ABC,CDF,KLT ABISKAR
ABC,CDF,KLT CORNEL
ABC,CDF,KLT KANNAD
JKL,HNM,KTY,KJY JAGAN
JKL,HNM,KTY,KJY HOUSE
JKL,HNM,KTY,KJY KATAK
JKL,HNM,KTY,KJY KOLKA
The o/p should be like
BUD,BDL BUDCAR,BUDLAMP
ABC,CDF,KLT... (4 Replies)
Discussion started by: jagdishrout
4 Replies
10. Shell Programming and Scripting
How can i comparing string's whith blank spaces?
I have this problem:
DIF1="STRING 1212"
DIF2="STRING 1212"
if
then
echo "Differents"
else
echo "Equals"
fi
Error:
1212}: unknown test operator (3 Replies)
Discussion started by: Xedrox
3 Replies
LEARN ABOUT PHP
array_diff_assoc
ARRAY_DIFF_ASSOC(3) 1 ARRAY_DIFF_ASSOC(3)
array_diff_assoc - Computes the difference of arrays with additional index check
SYNOPSIS
array array_diff_assoc (array $array1, array $array2, [array $...])
DESCRIPTION
Compares $array1 against $array2 and returns the difference. Unlike array_diff(3) the array keys are also used in the comparison.
PARAMETERS
o $array1
- The array to compare from
o $array2
- An array to compare against
o $...
- More arrays to compare against
RETURN VALUES
Returns an array containing all the values from $array1 that are not present in any of the other arrays.
EXAMPLES
Example #1
array_diff_assoc(3) example
In this example you see the "a" => "green" pair is present in both arrays and thus it is not in the output from the function.
Unlike this, the pair 0 => "red" is in the output because in the second argument "red" has key which is 1.
<?php
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
$array2 = array("a" => "green", "yellow", "red");
$result = array_diff_assoc($array1, $array2);
print_r($result);
?>
The above example will output:
Array
(
[b] => brown
[c] => blue
[0] => red
)
Example #2
array_diff_assoc(3) example
Two values from key => value pairs are considered equal only if (string) $elem1 === (string) $elem2 . In other words a strict check
takes place so the string representations must be the same.
<?php
$array1 = array(0, 1, 2);
$array2 = array("00", "01", "2");
$result = array_diff_assoc($array1, $array2);
print_r($result);
?>
The above example will output:
Array
(
[0] => 0
[1] => 1
)
NOTES
Note
This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example,
array_diff_assoc($array1[0], $array2[0]);.
Note
Ensure you pass arguments in the correct order when comparing similar arrays with more keys. The new array should be the first in
the list.
SEE ALSO
array_diff(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_intersect(3), array_intersect_assoc(3).
PHP Documentation Group ARRAY_DIFF_ASSOC(3)