Looking for en nicer solution for the next code:
for i in a b c
do
for j in A B C
do
for k in 1 2 3
do
echo "$i$j$k"
done
done
done
Sure is here some simpler solution.
This is a bit simpler
echo {a,b,c}{A,B,C}{1,2,3}
or if want one per line, so
echo {a,b,c}{A,B,C}{1,2,3} | xargs -n1
BTW, you can use the above bracer expansion for example saving keyboard typing for example when need make backup files, like:
cp /some/long/path/And_very-ugly-fileName{,.copy}
will make the /some/long/path/And_very-ugly-fileName.copy
without second filename typing.
Use a brace expansion:
echo {a,b,c}{A,B,C}{1,2,3}
This will print all possible combinations between the sets {a,b,c}
, {A,B,C}
, and {1,2,3}
.
Or even simpler, using ranges:
echo {a..c}{A..C}{1..3}
And if you want to print each combination per line, use a for
-loop:
for i in {a..c}{A..C}{1..3}; do echo $i; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With