Hello I would like to ask you, how can I write the same exact loop in bash
for (int i = 0; i < a; i++) {
for (int j = i; j < a; j++) {
System.out.println(i + " " + j);
}
}
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHello I would like to ask you, how can I write the same exact loop in bash
for (int i = 0; i < a; i++) {
for (int j = i; j < a; j++) {
System.out.println(i + " " + j);
}
}
bash
supports C-style for loops as follows:
a=5 # example
for ((i = 0; i < a; i++)); do
for ((j = i; j < a; j++)); do
echo "$i $j"
done
done
See here for more: http://www.tldp.org/LDP/abs/html/loops1.html