bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compare 2 arrays.


From: Quinn Fissler
Subject: Re: Compare 2 arrays.
Date: Wed, 30 May 2012 03:29:58 +0100

See any problem here?

########
#!/bin/bash
# [PL] Porownuje dwie tablice, zwraca prawde/falsz.
set -x
A=( "$1" )
B=( "$2" )
EQUAL=0

if [ address@hidden -eq address@hidden ]; then
for id in `seq 0 2 $[ address@hidden - 2 ]`; do
if [ "${A[ $id ]}" == "${B[ $id ]}" ]; then
EQUAL=1
else
EQUAL=0
break
fi
done
fi
echo $EQUAL

########
address@hidden:/home/dog$ ./pl.bash "ls" "ls"
+ A=("$1")
+ B=("$2")
+ EQUAL=0
+ '[' 1 -eq 1 ']'
++ seq 0 2 -1
+ echo 0
0
address@hidden:/home/dog$

########

On 29 May 2012 17:43, Akasei Yoshiko <address@hidden> wrote:
> I have something like that:
>
>> #!/bin/bash
>> # [PL] Porownuje dwie tablice, zwraca prawde/falsz.
>>
>> A=( "$1" )
>> B=( "$2" )
>> EQUAL=0
>>
>> if [ address@hidden -eq address@hidden ]; then
>>       for id in `seq 0 2 $[ address@hidden - 2 ]`; do
>>               if [ "${A[ $id ]}" == "${B[ $id ]}" ]; then
>>                       EQUAL=1
>>               else
>>                       EQUAL=0
>>                       break
>>               fi
>>       done
>> fi
>>
>> echo $EQUAL
>
>
> When i type:
>> user[~] $ ./compare "wget 0" "wget 0"
>> 0
>
> Returns zero.
>
> How do this properly?
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]