[olug] Bash script
David Walker
linux_user at grax.com
Thu Oct 24 18:37:29 UTC 2002
Are you trying to have cnd1 set to the first item in $condition1 and cnd2 set
to the first item in $condition2 and so forth?
#!/bin/sh
condition1="1 2 3 4 5 6"
condition2="9 8 7 6 5 0"
# change to arrays
condition1_arr=($condition1)
condition2_arr=($condition2)
let X=0
while [ $X -lt ${#condition1_arr[@]} ]; do
printf "cnd1=${condition1_arr[$X]}\n"
printf "cnd2=${condition2_arr[$X]}\n\n"
let X=$X+1
done
http://www.tldp.org/LDP/abs/html/arrays.html
On Thursday 24 October 2002 08:45 am, (Via wrote:
> Hi
>
> Can anyone help me with the following problem:
> I have two conditions which I want to check
> simultaneously in order to do some other things in
> bash script, i.e I want to do something similar to the
> following:
> condition1 = "1 2 3 4 5 6"
> condition2 = "9 8 7 6 5 0"
>
> for cnd1 in condition1 && for cnd2 in condition2
> do
> .....
> .....
> .....
> done
> but it can compile,it gives me a syntax error. I want
> to know if it is possible to combine two for loops
> with an "AND" or "OR" in basch script. If yes let me
> know.
>
> Thanks
>
>
> __________________________________________________
> Do you Yahoo!?
> Y! Web Hosting - Let the expert host your web site
> http://webhosting.yahoo.com/
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
More information about the OLUG
mailing list