Operating System - HP-UX
1820895 Members
3874 Online
109628 Solutions
New Discussion юеВ

Print the hexa decimal numbers in between.

 
SOLVED
Go to solution
KapilRaj
Honored Contributor

Print the hexa decimal numbers in between.

Hello folks,

A quick request. Please let me know a quick way of printing the hexa decimal numbers between 5B40 and 5B42. ( 5B40,5B41 and 5B42 )

Yes, you guessed it right. It is the output of symmaskdb list db from a symmetrix.

Thanks in advance. (There might be a perl one liner somewhere but I am not able to find it.

Regards,

Kaps
Nothing is impossible
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor
Solution

Re: Print the hexa decimal numbers in between.

Hi Kaps:

# perl -e 'printf "%0x\n",$_ for 0x5B40..0x5B42'

Regards!

...JRF...
KapilRaj
Honored Contributor

Re: Print the hexa decimal numbers in between.

Thanks you JRF ... Thanks a ton. ( Re-opening to assign points )
Nothing is impossible
James R. Ferguson
Acclaimed Contributor

Re: Print the hexa decimal numbers in between.

Hi (again):

Oops, the :

# perl -e 'printf "%0x\n",$_ for 0x5B40..0x5B42'

...was meant to be:

# perl -e 'printf "%#x\n",$_ for 0x5B40..0x5B42'

...if you want the output to include the leading '0x' to clearly signify hexadecimal. Drop that formatting directive if you don't want the '0x' but just the value.

Regards!

...JRF...

Dennis Handly
Acclaimed Contributor

Re: Print the hexadecimal numbers in between.

Or from a real shell:
typeset -i10 start=16#5B40 end=16#5B42
while (( start <= end )); do
    printf '0x%x\n' $start
    (( start += 1 ))
done

James R. Ferguson
Acclaimed Contributor

Re: Print the hexa decimal numbers in between.

Hi (again) Kaps:

If you want your output to contain lowercase (0x) use:

# perl -e 'printf "%#x\n",$_ for 0xf..0x20'

(or):

# perl -e 'printf "%x\n",$_ for 0xf..0x20'

If you want the output to show uppercase (0X), use:

# perl -e 'printf "%#X\n",$_ for 0xf..0x20'

(or):

perl -e 'printf "%X\n",$_ for 0xf..0x20'

The range you specify can be in any number base (octal [with a leading zero as '010']; decimal; or hexadecimal).

Regards!

...JRF...
KapilRaj
Honored Contributor

Re: Print the hexa decimal numbers in between.

You guys are awesome -- Thanks to all the responses.

I gave up on the hex conversion in the script. i.e. I was using "symmaskdb -sid list db" , now I changed it to symmaskdb -sid -wwn list devs # This one does not print the range :).

Thank you for the help. I am sure, I will run into this requirement in future. It was good education.

Regards, Kaps
Nothing is impossible
Rita C Workman
Honored Contributor

Re: Print the hexa decimal numbers in between.

In EMC-eze....

symdev list -RANGE 5b40:5B42

Rgrds,
Rita
Rita C Workman
Honored Contributor

Re: Print the hexa decimal numbers in between.

And if you only wanted the symdev number:

symdev list -RANGE 5B40:5B42 | awk '{print $1}'

Rita
KapilRaj
Honored Contributor

Re: Print the hexa decimal numbers in between.

Thank you ..
Nothing is impossible