LinkBack | Search this Thread |
#1 | |
Member Registered: Mar 2004 Distribution: Slackware 10.0 Posts: 55 Rep: | increment in hex [Log in to get rid of this advertisement] is there a way i can write a shell script that will be able to increment in hex? i.e. i was to get all the values from 000 to FFF |
#2 | |
Senior Member Registered: Jan 2003 Distribution: Debian 6.0.3, Ubuntu Server 10.04 Posts: 2,786 Rep: | Incrementing by one in hex is the same as incrementing by one in any other number base My suggestion: Do the increment like normal, and manually convert to hex format when you need to display or compare it to a hex value. For instance: Code: #!/bin/bash for number in $( seq 1 255 ) do hex_representation=$( printf "%X" ${number} ) echo "${number}: ${hex_representation}" done Code: number=$( printf "%d" 0x${hex_representation}" ) |
#3 | |
Member Registered: Jan 2005 Posts: 83 Rep: | Try this : Code: i=0 while [ $i -lt 4096 ] do x=`printf "%04X\n" $i` echo $x i=`expr $i + 1` done |
'via Blog this'
No comments:
Post a Comment