Sponsored Content
Full Discussion: ksh and hex numbers
Top Forums Shell Programming and Scripting ksh and hex numbers Post 302158196 by gus2000 on Monday 14th of January 2008 06:03:30 PM
Old 01-14-2008
The prefix "NNN#" in front of a number indicates the numeric base. From the ksh man page:

Quote:
Constants take the form [base#]n, where base is a decimal number
between two and thirty-six representing the arithmetic base and n is a
number in that base. If base is omitted, base 10 is used.
The typeset options are "-i" for "integer", and "-u" for "uppercase". But, since A was already typed as a hex integer, $a was converted.

The final step removes the leading base indicator. If you echo a constant that is not base 10, the base is printed.

Code:
# x=123:abc
# echo ${x#123:}        # trim from the left
ABC
# echo ${x%:ABC}        # trim from the right
123

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Req on how to convert hex numbers to decimals

Hi, If i have an input as c1:41 c2:0x0000.00046b3e I want to make output display as c1:41 c2:224062 . Basically convert first part 0x0000 (as hex) to decimal which is 0 and convert second part 0x00046b3e (as hex) to decimal which is 289598 and as such add both parts namely... (3 Replies)
Discussion started by: hare
3 Replies

2. Shell Programming and Scripting

ksh/awk help - output missing numbers

Here is what I am trying to do: I have a list of numbers that I pulled from an awk command in a column like so: 1 3 4 7 8 I want to find which numbers in the list are missing out of a range. So let's say I want to find out from the list above which numbers are missing from the... (6 Replies)
Discussion started by: afavis
6 Replies

3. Shell Programming and Scripting

How to convert hex numbers to decimal ?

Hi, please tell me how to convert hex number to decimal 000000E7 000000000002640D 0000000000025B16 and seconds to minutes, hours, days, months, years bytes to kbytes, mbytes , gbytes read the following examples while read a b do printf "%5d %5d\n" "0x$a" "0x$b" done < "$FILE"... (15 Replies)
Discussion started by: jack2
15 Replies

4. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

5. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

6. Shell Programming and Scripting

Range of numbers in HEX using AWK

Hi , How do i found out all the number in a range ( HEX) for example Input is 15CF:15D2 Output needed 15CF 15D0 15D1 15D2 Thanks (2 Replies)
Discussion started by: greycells
2 Replies

7. Shell Programming and Scripting

Convert Hex - KSH

Hello, I woild like to convert hex on KSH not BASH: I tried to use: tmp=31 printf "\x"${tmp}"" it works on bash - Output is '1' but not on ksh. please advice on the right syntax. Thanks. (4 Replies)
Discussion started by: LiorAmitai
4 Replies

8. Shell Programming and Scripting

Swapping a string of numbers between higher and lower order values(HEX)

I have this below string in a variable cutString=21222222222222222122222222222222 this string is nothing but hex values depicted as below 21:22:22:22:22:22:22:22:21:22:22:22:22:22:22:22 so what i want to achieve is swap the lower order with higher order values in the... (3 Replies)
Discussion started by: vivek d r
3 Replies

9. Shell Programming and Scripting

ksh Arithmetic syntax error while comparing decimal numbers

Hello, I am having a problem when i execute following script on RHEL 6.4. Same script works fine on another machine where I have same version of RHEL and KSH. Below is the rpm and RHEL version. ossvm12(0)> rpm -qa | grep ksh ksh-20100621-19.el6.x86_64 ossvm12(0)> cat... (7 Replies)
Discussion started by: Adithya Gokhale
7 Replies

10. Shell Programming and Scripting

ksh : split hex number group

Hi, sry for poor english I have a group of hex number as : 4D40:4D42 I want so split this group in a list as : 4D40,4D41,4D42 i don't know how i can do this in ksh Thanks (5 Replies)
Discussion started by: jocazh
5 Replies
rebase(1)						    BSD General Commands Manual 						 rebase(1)

NAME
rebase -- Changes base address of dylibs and bundles SYNOPSIS
rebase [-low_address addr] [-high_address addr] [-arch arch] [-v] file(s) DESCRIPTION
The base address of an image (dylib or bundle) is the preferred address for it to be loaded. By default all images are built with a base address of zero. At runtime, if the preferred memory range is already occupied, dyld will "slide" the image to a new address range. There is a small cost to the slide, as dyld must do some fix ups. The rebase tool takes a list of images and adjust their base address to be non- overlapping. If no low or high address is specified, the a suitable address range is choosen for the architecture. The options are as follows: -low_address addr Force the base address for the first image to be addr (specified in hex). Each subsequent file gets the next available base address. -high_address addr Force the base address for the last image to be such that when that image is loaded it occupies memory up to addr (specified in hex). Each preceeding file gets the previous available base address. -arch arch Only rebase the specified architecture. Other architectures in a universal image are left as is. -v Verbose. Print information about rebasing done. SEE ALSO
ld(1) Darwin June 6, 2006 Darwin
All times are GMT -4. The time now is 09:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy