How to test if array elements are all equal in bash?
Clash Royale CLAN TAG#URR8PPP
up vote
13
down vote
favorite
The following array represented the numbers of disks on each linux machines
Each single array includes the number of disks on a linux machine.
echo $ARRAY_DISK_Quantity[*]
4 4 4 4 2 4 4 4
what is the simple way to identify that all array's values are equal?
Good status:
4 4 4 4 4 4 4 4
Bad status:
4 4 4 4 4 4 2 4
Bad status:
6 6 6 6 6 6 6 6 6 6 2 6 2
bash shell-script awk array
add a comment |Â
up vote
13
down vote
favorite
The following array represented the numbers of disks on each linux machines
Each single array includes the number of disks on a linux machine.
echo $ARRAY_DISK_Quantity[*]
4 4 4 4 2 4 4 4
what is the simple way to identify that all array's values are equal?
Good status:
4 4 4 4 4 4 4 4
Bad status:
4 4 4 4 4 4 2 4
Bad status:
6 6 6 6 6 6 6 6 6 6 2 6 2
bash shell-script awk array
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35
add a comment |Â
up vote
13
down vote
favorite
up vote
13
down vote
favorite
The following array represented the numbers of disks on each linux machines
Each single array includes the number of disks on a linux machine.
echo $ARRAY_DISK_Quantity[*]
4 4 4 4 2 4 4 4
what is the simple way to identify that all array's values are equal?
Good status:
4 4 4 4 4 4 4 4
Bad status:
4 4 4 4 4 4 2 4
Bad status:
6 6 6 6 6 6 6 6 6 6 2 6 2
bash shell-script awk array
The following array represented the numbers of disks on each linux machines
Each single array includes the number of disks on a linux machine.
echo $ARRAY_DISK_Quantity[*]
4 4 4 4 2 4 4 4
what is the simple way to identify that all array's values are equal?
Good status:
4 4 4 4 4 4 4 4
Bad status:
4 4 4 4 4 4 2 4
Bad status:
6 6 6 6 6 6 6 6 6 6 2 6 2
bash shell-script awk array
edited Dec 25 '17 at 13:30
Jesse_b
10.5k22659
10.5k22659
asked Dec 25 '17 at 10:28
yael
2,0091145
2,0091145
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35
add a comment |Â
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35
add a comment |Â
7 Answers
7
active
oldest
votes
up vote
9
down vote
accepted
bash
+ GNU sort
+ GNU grep
solution:
if [ "$#array[@]" -gt 0 ] && [ $(printf "%s00" "$array[@]" |
LC_ALL=C sort -z -u |
grep -z -c .) -eq 1 ] ; then
echo ok
else
echo bad
fi
English explanation: if unique-sorting the elements of the array results in only one element, then print "ok". Otherwise print "bad".
The array is printed with NUL bytes separating each element, piped into GNU sort (relying on the -z
aka --zero-terminated
and -u
aka --unique
options), and then into grep
(using options -z
aka --null-data
and -c
aka --count
) to count the output lines.
Unlike my previous version, I can't use wc
here because it requires input lines terminated with a newline...and using sed
or tr
to convert NULs to newlines after the sort
would defeat the purpose of using NUL separators. grep -c
makes a reasonable substitute.
Here's the same thing rewritten as a function:
function count_unique()
local LC_ALL=C
if [ "$#" -eq 0 ] ; then
echo 0
else
echo "$(printf "%s00" "$@"
ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
if [ "$(count_unique "$ARRAY_DISK_Quantity[@]")" -eq 1 ] ; then
echo "ok"
else
echo "bad"
fi
1
Note thatsort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" onARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd wantLC_ALL=C sort -u
for byte-to-byte uniqueness.
â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
 |Â
show 3 more comments
up vote
7
down vote
With zsh
:
if (($#$(u)ARRAY_DISK_Quantity[@] == 1)); then
echo OK
else
echo not OK
fi
Where (u)
is a parameter expansion flag to expand unique values. So we're getting a count of the unique values in the array.
Replace == 1
with <= 1
is you want to consider an empty array is OK.
With ksh93
, you could sort the array and check that the first element is the same as the last:
set -s -- "$ARRAY_DISK_Quantity[@]"
if [ "$1" = "$@: -1" ]; then
echo OK
else
echo not OK
fi
With ksh88 or pdksh/mksh:
set -s -- "$ARRAY_DISK_Quantity[@]"
if eval '[ "$1" = "$'"$#"'" ]'; then
echo OK
else
echo not OK
fi
With bash
, you'd probably need a loop:
unique_values() return 1
done
return 0
if unique_values "$ARRAY_DISK_Quantity[@]"; then
echo OK
else
echo not OK
fi
(would work with all the Bourne-like shells with array support (ksh, zsh, bash, yash)).
Note that it returns OK for an empty array. Add a [ "$#" -gt 0 ] || return
at the start of the function if you don't want that.
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you usebash
?
â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page fortypeset
saysObsolete. See `help declare'.
Is there a reason you're using it instead oflocal
ordeclare
?
â wjandrea
Dec 26 '17 at 2:52
1
@wjandreatypeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to renametypeset
declare
and maketypeset
an alias to declare).
â Stéphane Chazelas
Dec 26 '17 at 7:32
add a comment |Â
up vote
4
down vote
bash
+ awk
soltion:
function get_status()
arr=("$@") # get the array passed as argument
if awk 'v && $1!=v exit 1 v=$1 ' <(printf "%dn" "$arr[@]"); then
echo "status: Ok"
else
echo "status: Bad"
fi
Test case #1:
ARRAY_DISK_Quantity=(4 4 4 4 4 2 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Bad
Test case #2:
ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Ok
add a comment |Â
up vote
4
down vote
I have another bash only solution that should work with strings as well:
isarray.equal ()
local placeholder="$1"
local num=0
while (( $# )); do
if [[ "$1" != "$placeholder" ]]; then
num=1
echo 'Bad' && break
fi
shift
done
[[ "$num" -ne 1 ]] && echo 'Okay'
Demonstration:
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four two four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four four four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
add a comment |Â
up vote
2
down vote
With bash and GNU grep:
if grep -qE '^([0-9]+)( 1)*$' <<< "$ARRAY_DISK_Quantity[@]"; then
echo "okay"
else
echo "not okay"
fi
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
add a comment |Â
up vote
1
down vote
Here is POSIX Awk:
awk 'BEGIN while (++z < ARGC) if (ARGV[z] != ARGV[1]) exit 1' "$ARRAY_DISK_Quantity[@]"
add a comment |Â
up vote
0
down vote
bash only solution (assuming a
is ARRAY_DISK_Quantity
)
ttt=$a[0]
res=0
for i in "$a[@]"
do
let res+=$(if [ "$ttt" -ne "$i" ]; then echo 1; else echo 0; fi);
done
if [ "$res" -eq 0 ]
then
echo "ok"
else
echo "bad"
fi
Works, but counts all errors when just one is enough:if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
add a comment |Â
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
accepted
bash
+ GNU sort
+ GNU grep
solution:
if [ "$#array[@]" -gt 0 ] && [ $(printf "%s00" "$array[@]" |
LC_ALL=C sort -z -u |
grep -z -c .) -eq 1 ] ; then
echo ok
else
echo bad
fi
English explanation: if unique-sorting the elements of the array results in only one element, then print "ok". Otherwise print "bad".
The array is printed with NUL bytes separating each element, piped into GNU sort (relying on the -z
aka --zero-terminated
and -u
aka --unique
options), and then into grep
(using options -z
aka --null-data
and -c
aka --count
) to count the output lines.
Unlike my previous version, I can't use wc
here because it requires input lines terminated with a newline...and using sed
or tr
to convert NULs to newlines after the sort
would defeat the purpose of using NUL separators. grep -c
makes a reasonable substitute.
Here's the same thing rewritten as a function:
function count_unique()
local LC_ALL=C
if [ "$#" -eq 0 ] ; then
echo 0
else
echo "$(printf "%s00" "$@"
ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
if [ "$(count_unique "$ARRAY_DISK_Quantity[@]")" -eq 1 ] ; then
echo "ok"
else
echo "bad"
fi
1
Note thatsort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" onARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd wantLC_ALL=C sort -u
for byte-to-byte uniqueness.
â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
 |Â
show 3 more comments
up vote
9
down vote
accepted
bash
+ GNU sort
+ GNU grep
solution:
if [ "$#array[@]" -gt 0 ] && [ $(printf "%s00" "$array[@]" |
LC_ALL=C sort -z -u |
grep -z -c .) -eq 1 ] ; then
echo ok
else
echo bad
fi
English explanation: if unique-sorting the elements of the array results in only one element, then print "ok". Otherwise print "bad".
The array is printed with NUL bytes separating each element, piped into GNU sort (relying on the -z
aka --zero-terminated
and -u
aka --unique
options), and then into grep
(using options -z
aka --null-data
and -c
aka --count
) to count the output lines.
Unlike my previous version, I can't use wc
here because it requires input lines terminated with a newline...and using sed
or tr
to convert NULs to newlines after the sort
would defeat the purpose of using NUL separators. grep -c
makes a reasonable substitute.
Here's the same thing rewritten as a function:
function count_unique()
local LC_ALL=C
if [ "$#" -eq 0 ] ; then
echo 0
else
echo "$(printf "%s00" "$@"
ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
if [ "$(count_unique "$ARRAY_DISK_Quantity[@]")" -eq 1 ] ; then
echo "ok"
else
echo "bad"
fi
1
Note thatsort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" onARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd wantLC_ALL=C sort -u
for byte-to-byte uniqueness.
â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
 |Â
show 3 more comments
up vote
9
down vote
accepted
up vote
9
down vote
accepted
bash
+ GNU sort
+ GNU grep
solution:
if [ "$#array[@]" -gt 0 ] && [ $(printf "%s00" "$array[@]" |
LC_ALL=C sort -z -u |
grep -z -c .) -eq 1 ] ; then
echo ok
else
echo bad
fi
English explanation: if unique-sorting the elements of the array results in only one element, then print "ok". Otherwise print "bad".
The array is printed with NUL bytes separating each element, piped into GNU sort (relying on the -z
aka --zero-terminated
and -u
aka --unique
options), and then into grep
(using options -z
aka --null-data
and -c
aka --count
) to count the output lines.
Unlike my previous version, I can't use wc
here because it requires input lines terminated with a newline...and using sed
or tr
to convert NULs to newlines after the sort
would defeat the purpose of using NUL separators. grep -c
makes a reasonable substitute.
Here's the same thing rewritten as a function:
function count_unique()
local LC_ALL=C
if [ "$#" -eq 0 ] ; then
echo 0
else
echo "$(printf "%s00" "$@"
ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
if [ "$(count_unique "$ARRAY_DISK_Quantity[@]")" -eq 1 ] ; then
echo "ok"
else
echo "bad"
fi
bash
+ GNU sort
+ GNU grep
solution:
if [ "$#array[@]" -gt 0 ] && [ $(printf "%s00" "$array[@]" |
LC_ALL=C sort -z -u |
grep -z -c .) -eq 1 ] ; then
echo ok
else
echo bad
fi
English explanation: if unique-sorting the elements of the array results in only one element, then print "ok". Otherwise print "bad".
The array is printed with NUL bytes separating each element, piped into GNU sort (relying on the -z
aka --zero-terminated
and -u
aka --unique
options), and then into grep
(using options -z
aka --null-data
and -c
aka --count
) to count the output lines.
Unlike my previous version, I can't use wc
here because it requires input lines terminated with a newline...and using sed
or tr
to convert NULs to newlines after the sort
would defeat the purpose of using NUL separators. grep -c
makes a reasonable substitute.
Here's the same thing rewritten as a function:
function count_unique()
local LC_ALL=C
if [ "$#" -eq 0 ] ; then
echo 0
else
echo "$(printf "%s00" "$@"
ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
if [ "$(count_unique "$ARRAY_DISK_Quantity[@]")" -eq 1 ] ; then
echo "ok"
else
echo "bad"
fi
edited Dec 25 '17 at 14:44
answered Dec 25 '17 at 11:17
cas
37.7k44394
37.7k44394
1
Note thatsort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" onARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd wantLC_ALL=C sort -u
for byte-to-byte uniqueness.
â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
 |Â
show 3 more comments
1
Note thatsort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" onARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd wantLC_ALL=C sort -u
for byte-to-byte uniqueness.
â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
1
1
Note that
sort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" on ARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd want LC_ALL=C sort -u
for byte-to-byte uniqueness.â Stéphane Chazelas
Dec 25 '17 at 11:58
Note that
sort -u
doesn't return unique elements but one of each set of elements that sort the same. For instance, it would say "ok" on ARRAY_DISK_Quantity=(â â¡)
on a GNU systems where locales typically decide those 2 characters sort the same. You'd want LC_ALL=C sort -u
for byte-to-byte uniqueness.â Stéphane Chazelas
Dec 25 '17 at 11:58
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
just another note it will be fail also in case no additional disks are appears from CLI so need also to add this syntax
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
[[ ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | wc -l ` -eq ` printf "%sn" "$ARRAY_DISK_Quantity[@]" | grep -c "0" ` ]] && echo fail
â yael
Dec 25 '17 at 12:22
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
@StéphaneChazelas the locale issue is worth dealing with, as is the IFS issue. Testing for an empty list is, IMO, best done separately - there's no need to check for non-unique elements in an empty set.
â cas
Dec 25 '17 at 12:53
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
Hi Cas I prefer your previous answer
â yael
Dec 25 '17 at 13:55
 |Â
show 3 more comments
up vote
7
down vote
With zsh
:
if (($#$(u)ARRAY_DISK_Quantity[@] == 1)); then
echo OK
else
echo not OK
fi
Where (u)
is a parameter expansion flag to expand unique values. So we're getting a count of the unique values in the array.
Replace == 1
with <= 1
is you want to consider an empty array is OK.
With ksh93
, you could sort the array and check that the first element is the same as the last:
set -s -- "$ARRAY_DISK_Quantity[@]"
if [ "$1" = "$@: -1" ]; then
echo OK
else
echo not OK
fi
With ksh88 or pdksh/mksh:
set -s -- "$ARRAY_DISK_Quantity[@]"
if eval '[ "$1" = "$'"$#"'" ]'; then
echo OK
else
echo not OK
fi
With bash
, you'd probably need a loop:
unique_values() return 1
done
return 0
if unique_values "$ARRAY_DISK_Quantity[@]"; then
echo OK
else
echo not OK
fi
(would work with all the Bourne-like shells with array support (ksh, zsh, bash, yash)).
Note that it returns OK for an empty array. Add a [ "$#" -gt 0 ] || return
at the start of the function if you don't want that.
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you usebash
?
â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page fortypeset
saysObsolete. See `help declare'.
Is there a reason you're using it instead oflocal
ordeclare
?
â wjandrea
Dec 26 '17 at 2:52
1
@wjandreatypeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to renametypeset
declare
and maketypeset
an alias to declare).
â Stéphane Chazelas
Dec 26 '17 at 7:32
add a comment |Â
up vote
7
down vote
With zsh
:
if (($#$(u)ARRAY_DISK_Quantity[@] == 1)); then
echo OK
else
echo not OK
fi
Where (u)
is a parameter expansion flag to expand unique values. So we're getting a count of the unique values in the array.
Replace == 1
with <= 1
is you want to consider an empty array is OK.
With ksh93
, you could sort the array and check that the first element is the same as the last:
set -s -- "$ARRAY_DISK_Quantity[@]"
if [ "$1" = "$@: -1" ]; then
echo OK
else
echo not OK
fi
With ksh88 or pdksh/mksh:
set -s -- "$ARRAY_DISK_Quantity[@]"
if eval '[ "$1" = "$'"$#"'" ]'; then
echo OK
else
echo not OK
fi
With bash
, you'd probably need a loop:
unique_values() return 1
done
return 0
if unique_values "$ARRAY_DISK_Quantity[@]"; then
echo OK
else
echo not OK
fi
(would work with all the Bourne-like shells with array support (ksh, zsh, bash, yash)).
Note that it returns OK for an empty array. Add a [ "$#" -gt 0 ] || return
at the start of the function if you don't want that.
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you usebash
?
â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page fortypeset
saysObsolete. See `help declare'.
Is there a reason you're using it instead oflocal
ordeclare
?
â wjandrea
Dec 26 '17 at 2:52
1
@wjandreatypeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to renametypeset
declare
and maketypeset
an alias to declare).
â Stéphane Chazelas
Dec 26 '17 at 7:32
add a comment |Â
up vote
7
down vote
up vote
7
down vote
With zsh
:
if (($#$(u)ARRAY_DISK_Quantity[@] == 1)); then
echo OK
else
echo not OK
fi
Where (u)
is a parameter expansion flag to expand unique values. So we're getting a count of the unique values in the array.
Replace == 1
with <= 1
is you want to consider an empty array is OK.
With ksh93
, you could sort the array and check that the first element is the same as the last:
set -s -- "$ARRAY_DISK_Quantity[@]"
if [ "$1" = "$@: -1" ]; then
echo OK
else
echo not OK
fi
With ksh88 or pdksh/mksh:
set -s -- "$ARRAY_DISK_Quantity[@]"
if eval '[ "$1" = "$'"$#"'" ]'; then
echo OK
else
echo not OK
fi
With bash
, you'd probably need a loop:
unique_values() return 1
done
return 0
if unique_values "$ARRAY_DISK_Quantity[@]"; then
echo OK
else
echo not OK
fi
(would work with all the Bourne-like shells with array support (ksh, zsh, bash, yash)).
Note that it returns OK for an empty array. Add a [ "$#" -gt 0 ] || return
at the start of the function if you don't want that.
With zsh
:
if (($#$(u)ARRAY_DISK_Quantity[@] == 1)); then
echo OK
else
echo not OK
fi
Where (u)
is a parameter expansion flag to expand unique values. So we're getting a count of the unique values in the array.
Replace == 1
with <= 1
is you want to consider an empty array is OK.
With ksh93
, you could sort the array and check that the first element is the same as the last:
set -s -- "$ARRAY_DISK_Quantity[@]"
if [ "$1" = "$@: -1" ]; then
echo OK
else
echo not OK
fi
With ksh88 or pdksh/mksh:
set -s -- "$ARRAY_DISK_Quantity[@]"
if eval '[ "$1" = "$'"$#"'" ]'; then
echo OK
else
echo not OK
fi
With bash
, you'd probably need a loop:
unique_values() return 1
done
return 0
if unique_values "$ARRAY_DISK_Quantity[@]"; then
echo OK
else
echo not OK
fi
(would work with all the Bourne-like shells with array support (ksh, zsh, bash, yash)).
Note that it returns OK for an empty array. Add a [ "$#" -gt 0 ] || return
at the start of the function if you don't want that.
edited Dec 25 '17 at 12:43
answered Dec 25 '17 at 11:50
Stéphane Chazelas
282k53518851
282k53518851
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you usebash
?
â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page fortypeset
saysObsolete. See `help declare'.
Is there a reason you're using it instead oflocal
ordeclare
?
â wjandrea
Dec 26 '17 at 2:52
1
@wjandreatypeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to renametypeset
declare
and maketypeset
an alias to declare).
â Stéphane Chazelas
Dec 26 '17 at 7:32
add a comment |Â
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you usebash
?
â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page fortypeset
saysObsolete. See `help declare'.
Is there a reason you're using it instead oflocal
ordeclare
?
â wjandrea
Dec 26 '17 at 2:52
1
@wjandreatypeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to renametypeset
declare
and maketypeset
an alias to declare).
â Stéphane Chazelas
Dec 26 '17 at 7:32
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
all these answers not seems to support bash ?
â yael
Dec 25 '17 at 12:04
@yael, see edit for a bash solution. But why would you use
bash
?â Stéphane Chazelas
Dec 25 '17 at 12:08
@yael, see edit for a bash solution. But why would you use
bash
?â Stéphane Chazelas
Dec 25 '17 at 12:08
In Bash, the help page for
typeset
says Obsolete. See `help declare'.
Is there a reason you're using it instead of local
or declare
?â wjandrea
Dec 26 '17 at 2:52
In Bash, the help page for
typeset
says Obsolete. See `help declare'.
Is there a reason you're using it instead of local
or declare
?â wjandrea
Dec 26 '17 at 2:52
1
1
@wjandrea
typeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to rename typeset
declare
and make typeset
an alias to declare).â Stéphane Chazelas
Dec 26 '17 at 7:32
@wjandrea
typeset
is the one that works in all 4 shells. It's also the original one from ksh in the early 80s ( bash mostly copied ksh88 when it comes to variable scoping type setting and declaration but decided to rename typeset
declare
and make typeset
an alias to declare).â Stéphane Chazelas
Dec 26 '17 at 7:32
add a comment |Â
up vote
4
down vote
bash
+ awk
soltion:
function get_status()
arr=("$@") # get the array passed as argument
if awk 'v && $1!=v exit 1 v=$1 ' <(printf "%dn" "$arr[@]"); then
echo "status: Ok"
else
echo "status: Bad"
fi
Test case #1:
ARRAY_DISK_Quantity=(4 4 4 4 4 2 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Bad
Test case #2:
ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Ok
add a comment |Â
up vote
4
down vote
bash
+ awk
soltion:
function get_status()
arr=("$@") # get the array passed as argument
if awk 'v && $1!=v exit 1 v=$1 ' <(printf "%dn" "$arr[@]"); then
echo "status: Ok"
else
echo "status: Bad"
fi
Test case #1:
ARRAY_DISK_Quantity=(4 4 4 4 4 2 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Bad
Test case #2:
ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Ok
add a comment |Â
up vote
4
down vote
up vote
4
down vote
bash
+ awk
soltion:
function get_status()
arr=("$@") # get the array passed as argument
if awk 'v && $1!=v exit 1 v=$1 ' <(printf "%dn" "$arr[@]"); then
echo "status: Ok"
else
echo "status: Bad"
fi
Test case #1:
ARRAY_DISK_Quantity=(4 4 4 4 4 2 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Bad
Test case #2:
ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Ok
bash
+ awk
soltion:
function get_status()
arr=("$@") # get the array passed as argument
if awk 'v && $1!=v exit 1 v=$1 ' <(printf "%dn" "$arr[@]"); then
echo "status: Ok"
else
echo "status: Bad"
fi
Test case #1:
ARRAY_DISK_Quantity=(4 4 4 4 4 2 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Bad
Test case #2:
ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
get_status "$ARRAY_DISK_Quantity[@]"
status: Ok
edited Dec 25 '17 at 11:00
answered Dec 25 '17 at 10:45
RomanPerekhrest
22.4k12145
22.4k12145
add a comment |Â
add a comment |Â
up vote
4
down vote
I have another bash only solution that should work with strings as well:
isarray.equal ()
local placeholder="$1"
local num=0
while (( $# )); do
if [[ "$1" != "$placeholder" ]]; then
num=1
echo 'Bad' && break
fi
shift
done
[[ "$num" -ne 1 ]] && echo 'Okay'
Demonstration:
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four two four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four four four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
add a comment |Â
up vote
4
down vote
I have another bash only solution that should work with strings as well:
isarray.equal ()
local placeholder="$1"
local num=0
while (( $# )); do
if [[ "$1" != "$placeholder" ]]; then
num=1
echo 'Bad' && break
fi
shift
done
[[ "$num" -ne 1 ]] && echo 'Okay'
Demonstration:
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four two four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four four four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
add a comment |Â
up vote
4
down vote
up vote
4
down vote
I have another bash only solution that should work with strings as well:
isarray.equal ()
local placeholder="$1"
local num=0
while (( $# )); do
if [[ "$1" != "$placeholder" ]]; then
num=1
echo 'Bad' && break
fi
shift
done
[[ "$num" -ne 1 ]] && echo 'Okay'
Demonstration:
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four two four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four four four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
I have another bash only solution that should work with strings as well:
isarray.equal ()
local placeholder="$1"
local num=0
while (( $# )); do
if [[ "$1" != "$placeholder" ]]; then
num=1
echo 'Bad' && break
fi
shift
done
[[ "$num" -ne 1 ]] && echo 'Okay'
Demonstration:
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 2 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(4 4 4 4 4 4 4 4)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four two four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Bad
[root@JBSTEST001 ~]# ARRAY_DISK_Quantity=(four four four four four four four four)
[root@JBSTEST001 ~]# isarray.equal "$ARRAY_DISK_Quantity[@]"
Okay
edited Dec 25 '17 at 13:56
answered Dec 25 '17 at 12:25
Jesse_b
10.5k22659
10.5k22659
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
add a comment |Â
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
Note that dots are not valid in function names, though Bash is pretty permissive. This may cause issues like in exporting the function.
â wjandrea
Dec 26 '17 at 2:55
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
unix.stackexchange.com/a/245953/237982
â Jesse_b
Dec 26 '17 at 3:30
add a comment |Â
up vote
2
down vote
With bash and GNU grep:
if grep -qE '^([0-9]+)( 1)*$' <<< "$ARRAY_DISK_Quantity[@]"; then
echo "okay"
else
echo "not okay"
fi
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
add a comment |Â
up vote
2
down vote
With bash and GNU grep:
if grep -qE '^([0-9]+)( 1)*$' <<< "$ARRAY_DISK_Quantity[@]"; then
echo "okay"
else
echo "not okay"
fi
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
add a comment |Â
up vote
2
down vote
up vote
2
down vote
With bash and GNU grep:
if grep -qE '^([0-9]+)( 1)*$' <<< "$ARRAY_DISK_Quantity[@]"; then
echo "okay"
else
echo "not okay"
fi
With bash and GNU grep:
if grep -qE '^([0-9]+)( 1)*$' <<< "$ARRAY_DISK_Quantity[@]"; then
echo "okay"
else
echo "not okay"
fi
edited Dec 30 '17 at 6:39
answered Dec 25 '17 at 16:02
Cyrus
7,0362835
7,0362835
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
add a comment |Â
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
Yes, but what about (10 10 10 10)? Otherwise, quite nice.
â Joe
Dec 30 '17 at 6:20
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
@Joe: Good catch. I've updated my answer.
â Cyrus
Dec 30 '17 at 6:39
add a comment |Â
up vote
1
down vote
Here is POSIX Awk:
awk 'BEGIN while (++z < ARGC) if (ARGV[z] != ARGV[1]) exit 1' "$ARRAY_DISK_Quantity[@]"
add a comment |Â
up vote
1
down vote
Here is POSIX Awk:
awk 'BEGIN while (++z < ARGC) if (ARGV[z] != ARGV[1]) exit 1' "$ARRAY_DISK_Quantity[@]"
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here is POSIX Awk:
awk 'BEGIN while (++z < ARGC) if (ARGV[z] != ARGV[1]) exit 1' "$ARRAY_DISK_Quantity[@]"
Here is POSIX Awk:
awk 'BEGIN while (++z < ARGC) if (ARGV[z] != ARGV[1]) exit 1' "$ARRAY_DISK_Quantity[@]"
answered Dec 25 '17 at 22:29
Steven Penny
2,30821635
2,30821635
add a comment |Â
add a comment |Â
up vote
0
down vote
bash only solution (assuming a
is ARRAY_DISK_Quantity
)
ttt=$a[0]
res=0
for i in "$a[@]"
do
let res+=$(if [ "$ttt" -ne "$i" ]; then echo 1; else echo 0; fi);
done
if [ "$res" -eq 0 ]
then
echo "ok"
else
echo "bad"
fi
Works, but counts all errors when just one is enough:if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
add a comment |Â
up vote
0
down vote
bash only solution (assuming a
is ARRAY_DISK_Quantity
)
ttt=$a[0]
res=0
for i in "$a[@]"
do
let res+=$(if [ "$ttt" -ne "$i" ]; then echo 1; else echo 0; fi);
done
if [ "$res" -eq 0 ]
then
echo "ok"
else
echo "bad"
fi
Works, but counts all errors when just one is enough:if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
add a comment |Â
up vote
0
down vote
up vote
0
down vote
bash only solution (assuming a
is ARRAY_DISK_Quantity
)
ttt=$a[0]
res=0
for i in "$a[@]"
do
let res+=$(if [ "$ttt" -ne "$i" ]; then echo 1; else echo 0; fi);
done
if [ "$res" -eq 0 ]
then
echo "ok"
else
echo "bad"
fi
bash only solution (assuming a
is ARRAY_DISK_Quantity
)
ttt=$a[0]
res=0
for i in "$a[@]"
do
let res+=$(if [ "$ttt" -ne "$i" ]; then echo 1; else echo 0; fi);
done
if [ "$res" -eq 0 ]
then
echo "ok"
else
echo "bad"
fi
answered Dec 25 '17 at 10:58
Bhavin Chirag
1514
1514
Works, but counts all errors when just one is enough:if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
add a comment |Â
Works, but counts all errors when just one is enough:if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
Works, but counts all errors when just one is enough:
if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
Works, but counts all errors when just one is enough:
if [ "$ttt" -ne "$i" ]; then res=1; break; fi;
â Joe
Dec 30 '17 at 6:30
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412933%2fhow-to-test-if-array-elements-are-all-equal-in-bash%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
So many answers and no votes?
â Jesse_b
Dec 25 '17 at 11:59
Will this only be testing integers or should it also test strings?
â Jesse_b
Dec 25 '17 at 12:01
I just waiting for the best answer dont worry soon I will vote
â yael
Dec 25 '17 at 12:02
I meant everyone else. This question deserves upvote IMO.
â Jesse_b
Dec 25 '17 at 12:03
once you need something of at least this level of complexity, it's a good time to start using a real programming language, until it's too lateâ¦
â Sarge Borsch
Dec 26 '17 at 17:35