sea
1
Heyas
I want to list passed arguments and make an incrementing 'marker'.
That 'marker' should be a letter between a-z, in proper order.
I'm not aware of a seq pendant, so i tried it with this:
C=141
list=""
while [[ $C -lt 173 ]];do
printf \\$C
list+=" \\$C"
C=$((C+1))
done
echo
echo $list
But the output is quite confusing
abcdefg
8
9pqrstuvw89xyzmno
\141 \142 \143 \144 \145 \146 \147 \148 \149 \150 \151 \152 \153 \154 \155 \156 \157 \158 \159 \160 \161 \162 \163 \164 \165 \166 \167 \168 \169 \170 \171 \172
Any advices please?
Thank you in advance
RudiC
2
\148 \149 \158 \159
etc. can't be interpreted as octal numbers, so the output (without further investigation) is a bit dubious.
---------- Post updated at 12:03 ---------- Previous update was at 11:59 ----------
BTW, in bash
you have
echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
1 Like
sea
3
I guess it would be easier to make a simple hardcoded letter-list?
EDIT:
Thank you RudiC
---------- Post updated at 12:58 ---------- Previous update was at 12:05 ----------
So, having now a function to 'transform' a number into a letter.
Any performance suggestions?
list=( $(echo {a..z} ))
num2char() { # NUM
# Returns a letter string: a-z
# Or: aa-az ba-bz, etc
num=$1
out=""
if [[ $num -lt ${#list[@]} ]]
then out="${list[$num]}"
else high=$[ $num / ${#list[@]} ]
out="${list[$high-1]}${list[$num - ($high * ${#list[@]})]}"
fi
echo "$out"
}
time ./tui-list -a {a..z} \
{a..z} {a..z} {a..z} \
{a..z} {a..z} {a..z} \
{a..z} {a..z} {a..z} \
{a..z} {a..z} {a..z} \
{a..z} {a..z} {a..z}
..
...
# | ox) x | #
# | oy) y | #
# | oz) z | #
DEBUG 416 lines shown
real 0m2.671s
user 0m0.788s
sys 0m0.609s
Have a good day
EDIT:
Ouch, without tui-echo, but just echo, its like more than 2 secs faster..
Guess it's all fine then
...
oz) z
DEBUG 416 lines shown
real 0m0.218s
user 0m0.030s
sys 0m0.041s
Guess its the interface causing the slowness.
RudiC
4
To get
# Or: aa-az ba-bz, etc
: did you try
echo {a..b}{a..z}
aa ab ac ad ae af ag ah . . . bw bx by bz
1 Like