looping in hexadecimal with bash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers looping in hexadecimal with bash
# 1  
Old 07-01-2008
looping in hexadecimal with bash

hello every one this is my first post ... well i'm new to linux ....
i've been enjoying shell scripting tutorials and i'm new to writting scripts

i want to write a script that creates a directory tree named in hexadecimal but i'm stuck at the hexadecimal part ... here is my code (incase i was dealing with intergers ...using bash)
max=39
for((i=1;i<=max;i++))
do
mkdir $i
cd$i
done

i have tried using "typeset i16 i" but this gives me an error in bash but it works with ksh yet it names my directories with the "16#" part in ksh ...
any suggestions on how i can improve my code ... and can i make it work in bash and ksh esp bash ... i've seen posts like mine on the topic of hexadecimals but, ksh was the remedy.
# 2  
Old 07-01-2008
solved

problem has been solved with
Code:
printf

thanks
# 3  
Old 07-01-2008
No duplicate or cross-posting, read the rules.

Proceed here:

https://www.unix.com/shell-programmin...#post302210608

Thread closed.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate hexadecimal

Hello I'm working on a script to list all ipv6 from given address so I've run this script which create hex part of ipv6 STR2=159 END2=200 SUM2=`expr $END2 - $STR2` for ((i=STR2;i<=END2;++i)); do x=$( printf "%x" $i ) ; echo $x echo -e "::"$x >> netpart.txt done output is : ::9f... (2 Replies)
Discussion started by: nimafire
2 Replies

2. Shell Programming and Scripting

Bash Script Looping all the time

Hello, I have a database file, named data.txt, and a shell script (convert.sh) to convert data.txt from columns to row. Output file name will be column_to_row.txt In this example data.txt has only four rows. Format of data.txt is: info name surname telefon_nr Data.txt info boris... (1 Reply)
Discussion started by: baris35
1 Replies

3. UNIX for Advanced & Expert Users

6-digit hexadecimal ID in shell

Hi, i tried to do this script: Generate a "unique" 6-digit hexadecimal identifier for your computer. Do not use the flawed hostid command. Hint: md5sum /etc/passwd, then select the first 6 digits of output. Fom 0 to 9 and from a to f #!/bin/bash clear echo "" echo "--------------------"... (4 Replies)
Discussion started by: jose2802
4 Replies

4. Shell Programming and Scripting

Looping structure to make up for lack of bash GOTO

Hello, I am re-processing some files when a specific condition is met. The condition is read from the filename. Since files may need to be re-processed a number of times before they no longer meet the condition, I need to know when to stop re-processing. I am having trouble visualizing the... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

5. Shell Programming and Scripting

Looping Bash Script

Does anyone have a same of a bash script that cd to a directory and execute a cgi script then moves onto the next directory then executes another cgi ? (3 Replies)
Discussion started by: Virusbot
3 Replies

6. Shell Programming and Scripting

hexadecimal replacing with awk ?

Hi there ! I have text files with some nonsense characters in it, so different text editors put different nonsense symbols, and, worse, the application that should be able to read these files doesn't. With xxd, the nonsense characters show as "efbfbd", while they should be "c2a7" (the... (2 Replies)
Discussion started by: jossojjos
2 Replies

7. Programming

Hexadecimal to ascii

Let's suppose i have a hexadecimal array with 16 cells.for example b3e2d5f636111780 i want to convert it to an array of ascii characters(in C) so that i can reduce total size of the file i want to put it in. But i am afraid i have not fully understand the difference between ascii and hex(i... (3 Replies)
Discussion started by: bashuser2
3 Replies

8. UNIX for Dummies Questions & Answers

Hexadecimal to Decimal

Hi all, I have a small script to convert my HexaDecimal Input to Decimal as output. #!/bin/ksh hd=00208060 dec=`printf %d $hd` echo $dec Output of the above program: printf: 00208060 not completely converted 16 But my expected output is "2130016". How can i acheive this. I... (2 Replies)
Discussion started by: Arunprasad
2 Replies

9. Shell Programming and Scripting

looping in hexadecimal with bash

i want to write a script that creates a directory tree named in hexadecimal but i'm stuck at the hexadecimal part ... here is my code (incase i was dealing with intergers ...using bash) max=39 for((i=1;i<=max;i++)) do mkdir $i cd $i done i have tried using "typeset i16 i" but... (7 Replies)
Discussion started by: soba
7 Replies

10. Shell Programming and Scripting

Get Hexadecimal Value

I have a record in a file that ends with the new line character "\n". How dio I determine the hexadecimal value for that? (2 Replies)
Discussion started by: lesstjm
2 Replies
Login or Register to Ask a Question