New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Help Needed: Scripting
I'm a n00b on programming/scripting so if anyone can help me please, I'd appreciate it.
How do you output hex chars on shell script? My goal is 5 characters long and increments it up until the end.
00000
00001
. . .
. . .
0000A
...
0001F
thank you!

Comments
Kabayan:
Try this
max=39
for((i=0;i<=max;i++))
do
str=$(printf "%05x" $i)
echo $str
done
Just replace 39 with a very high value
salamat!
here's the output
./test: line 6: syntax error: unexpected end of fileoh my bad.. "done" is actually part of it.. Thanks!
Try
bash test
-
Or put a
#!/bin/bash on top of file
#!/bin/bash # # hexcount - POSIX Shell script to count from $1 to $2 in hex, # separated by ";" and with the precision set to the # maximum digits of $1 and $2. # Usage: hexcount lo hi # Example: hexcount FFF 1200 FROM=$1 TO=$2 if test ${#FROM} -gt ${#TO}; then FORMAT="%0${#FROM}X;" else FORMAT="%0${#TO}X;" fi FROM=$(printf '%d' 0x$FROM) TO=$(printf '%d' 0x$TO) while test $FROM -le $TO; do printf $FORMAT $FROM FROM=$((FROM+1)) done printf '\n'Nice code
woah.. cool.. thanks @jcaleb and @prae5