The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
conversion infyanurag Shell Programming and Scripting 3 06-02-2008 02:04 AM
.xls to .csv conversion neil546 Shell Programming and Scripting 7 07-17-2007 04:55 AM
conversion rajan_ka1 UNIX for Advanced & Expert Users 1 03-14-2006 07:56 AM
String Conversion in awk rohanrege Shell Programming and Scripting 3 02-14-2005 05:05 PM
X.25 to TCP/IP conversion manjunath IP Networking 2 08-20-2002 09:57 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-20-2007
insania insania is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 30
Hex Conversion

I need to have my scripts import volume groups and mknod devices files. I have most of the script working but the device file needs to be in the format 0x??0000 (where the question marks are my HEX representations of the volume group number. I have the code below and the output it produces which would work great except anything that is only one charater will not work (I.E "1" needs to be "01", "a" needs to be "0a"). Any suggestions? And I can't use any perl code.

#!/bin/sh

for y in vg01 vg02 vg03 vg10 vg21 vg22 vg23
do
printf "%#x\n" $(echo ${y} | sed 's/^vg//') | sed 's/0x//'
done



Output:

1
2
3
a
15
16
17
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0