09-12-2013
Right .... I wanted to use this on Solaris which does not have GAWK and thus cannot use strtonum function .... thx
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi I want to incremental add hex decimal number to a particula field in file
eg: addr =123 dept1=0
addr = 345 dept2 =1
addr2 = 124 dept3 =2
.
.
.
.
.
.
addr3 =567 dept15 =f
Is there any command which add... (8 Replies)
Discussion started by: diddi_linux
8 Replies
2. Shell Programming and Scripting
Hi,
I have a data as follow:
1 400
2 239
3 871
4 219
5 543
6 ...
7 ...
.. ...
.. ...
99 818
100 991
I want to replace the sequence number (column 1) that start from 150. The output should like this:
150 400
151 239 (3 Replies)
Discussion started by: nica
3 Replies
3. Shell Programming and Scripting
Friends, I am looking for a small script which generates HEX sequence. Input to the script is starting hex number - Group ID and number of members a group should have and total groups.
e.g: Here we are generating 2 groups with 4 Members each starting with hex 036A.
Output:
Group ID 036A,... (5 Replies)
Discussion started by: dynamax
5 Replies
4. Shell Programming and Scripting
Guys, I am looking for a small script which generates HEX sequence. Input to the script is starting hex number - Group ID and number of members in a group and total groups.
e.g: we are generating 2 groups with 4 Members each starting with hex number 036A. I should get o/p in following format.
... (5 Replies)
Discussion started by: dynamax
5 Replies
5. Shell Programming and Scripting
Is it possible by using awk to remove leading zeros for a hex number?
ex:
0000000011179E0A -> 11179E0A
Thank you! (4 Replies)
Discussion started by: carloszhang
4 Replies
6. Shell Programming and Scripting
$ awk 'BEGIN{ pat111=0x1000000002E3E02; snBegin=0x1000000002E3E01; if (pat111<=snBegin) printf "a\n"}'
a
Result is not correct.
Looks like the number is too big.
Any idea?
Thx!
Please use code tags <- click the link! (2 Replies)
Discussion started by: carloszhang
2 Replies
7. Shell Programming and Scripting
Dear Perl users,
I need your help to solve my problem below.
I want to print the sequence number without missing number within the range.
E.g. my sequence number :
1 2 3 4 5 6 7 8 11 12 13 14
my desired output:
1 -8 , 11-14
my code below but still problem with the result:
1 - 14
1 -... (2 Replies)
Discussion started by: mandai
2 Replies
8. Shell Programming and Scripting
Am using unix aix KSH...
I have the files called
MMRR0106.DAT
MMRR0206.DAT
MMRR0406.DAT
MMRR0506.DAT
MMRR0806.DAT
....
...
MMRR3006.DAT
MMRR0207.DAT
These files are in one dircetory /venky ?
I want the output like this ?
Missing files are :
MMRR0306.DAT
MMRR0606.DAT... (7 Replies)
Discussion started by: Venkatesh1
7 Replies
9. Shell Programming and Scripting
Hi all,
I have a file like this
ID 3BP5L_HUMAN Reviewed; 393 AA.
AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3;
DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot.
DT 05-JUL-2004, sequence version 1.
DT 05-SEP-2012, entry version 71.
FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies
10. Shell Programming and Scripting
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
LEARN ABOUT FREEBSD
strtonum
STRTONUM(3) BSD Library Functions Manual STRTONUM(3)
NAME
strtonum -- reliably convert string value to an integer
SYNOPSIS
#include <stdlib.h>
long long
strtonum(const char *nptr, long long minval, long long maxval, const char **errstr);
DESCRIPTION
The strtonum() function converts the string in nptr to a long long value. The strtonum() function was designed to facilitate safe, robust
programming and overcome the shortcomings of the atoi(3) and strtol(3) family of interfaces.
The string may begin with an arbitrary amount of whitespace (as determined by isspace(3)) followed by a single optional '+' or '-' sign.
The remainder of the string is converted to a long long value according to base 10.
The value obtained is then checked against the provided minval and maxval bounds. If errstr is non-null, strtonum() stores an error string
in *errstr indicating the failure.
RETURN VALUES
The strtonum() function returns the result of the conversion, unless the value would exceed the provided bounds or is invalid. On error, 0
is returned, errno is set, and errstr will point to an error message. On success, *errstr will be set to NULL; this fact can be used to dif-
ferentiate a successful return of 0 from an error.
EXAMPLES
Using strtonum() correctly is meant to be simpler than the alternative functions.
int iterations;
const char *errstr;
iterations = strtonum(optarg, 1, 64, &errstr);
if (errstr != NULL)
errx(1, "number of iterations is %s: %s", errstr, optarg);
The above example will guarantee that the value of iterations is between 1 and 64 (inclusive).
ERRORS
[ERANGE] The given string was out of range.
[EINVAL] The given string did not consist solely of digit characters.
[EINVAL] The supplied minval was larger than maxval.
If an error occurs, errstr will be set to one of the following strings:
too large The result was larger than the provided maximum value.
too small The result was smaller than the provided minimum value.
invalid The string did not consist solely of digit characters.
SEE ALSO
atof(3), atoi(3), atol(3), atoll(3), sscanf(3), strtod(3), strtol(3), strtoul(3)
STANDARDS
The strtonum() function is a BSD extension. The existing alternatives, such as atoi(3) and strtol(3), are either impossible or difficult to
use safely.
HISTORY
The strtonum() function first appeared in OpenBSD 3.6.
BSD
April 29, 2004 BSD