So I made this file and I am currently running it within a bash shell and it lists fine, however each result is placed on its own individual line. I was wondering how I would make the same program, but make it place the results laterally, one result after another.
x=0;while [ $x -le 256 ]
do
t=$(tput sgr 0);r=$(tput setaf $x);echo "${r} $x ${t}";((x=$x+1))
done
How i understand, u need something like this:
x=0;while [ $x -le 256 ]
do
t=$(tput sgr 0);r=$(tput setaf $x);echo -n "${r} $x ${t}";((x=$x+1))
done
U forgot to use echo -n (no new line)
Formatted version with columns:
#!/bin/bash
t=$(tput sgr 0)
for x in {0..255}; do
printf "%s%4s${t}" "$(tput setaf $x)" $x
if [ $((x % 15)) -eq 0 ]; then echo; fi;
done