I got a task to display all bash fonts/colors/background colors in table where the text is different for each variation and is being taken from file that contains 448 words/random number(I'm working with numbers). Here is my code for displaying all variations
for i in {0..8}; do for j in {30..37}; do for n in {40..47}; do echo -ne "\e[$i;$j;$n""mcolors" done echo done done echo "" Output: enter image description here
Code for generating random numbers:
#!/bin/bash for ((i=0;i<$1;i++)) do echo $RANDOM >> randomnumbers.sh done So the question is how can I pass numbers from randomnumbers.sh to my script so "colors" line in output changes to number being taken by order from randomnumbers.sh? Thanks!
|instead of»?»is just a symbol without special meaning, and>>would append the random number to the first script file.randomnumbers.shwhich incidentally has a misleading name (as it's just text (a sequence of random numbers, not a shell script), you could just generate it in place. If that's not an option I'd be rewriting the lot.>> randomnumbers.shoff yourecho, and instead put it on thedone; that is:for ((i=0; i<$1; i++)); do echo "$RANDOM"; done >randomnumbers-- that way you only open the output file once and keep re-using that single open file descriptor for the whole loop, instead of re-opening the output file hundreds of times (and closing/flushing it after every single write).echo(which explicitly states thatprintfshould be used instead ifechowould otherwise be passed an argument with backslash-escape sequences or an initial word of-n).