10-22-2015
Quote:
Originally Posted by
RudiC
Would using %.f as a format string help?
I'm assuming that the problem is the conversion of the string
0x concatenated with a hex-digit string into a number stopping at the
x rather than there being a problem with a
%d,
%u, or
%f format specifier, but this is certainly worth a try. Just for the fun of it, we should also try
%d as well as
%.f instead of
%u.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello !
Does anyone knows how can I convert hexadecimal to decimal base in the ksh or csh script ??
Thanks !
Witt (1 Reply)
Discussion started by: witt
1 Replies
2. Shell Programming and Scripting
Hi frnds :)
I need a small help...
I have a very long file containing 20 digits decimal number which i want to convert into the corresponding 16 digit hexadecimal values.
File looks like....
11908486672755551741
05446378739602232559
04862605079740156652
.
.
.
I tried the script
for i... (7 Replies)
Discussion started by: vanand420
7 Replies
3. Shell Programming and Scripting
hi ,
i need a script to convert number into hexadecimal base
for example: 237=>ED
it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies
4. UNIX for Dummies Questions & Answers
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
5. Shell Programming and Scripting
Hi,
Here is my script to read a file into array:
awk -F '+' '
# load first file into array indexed by fields 1 and 2
NR == FNR {
file1nr = FNR
for (i=3; i<NF; i++) {
file1 = $i
}
I have this... (5 Replies)
Discussion started by: Sangtha
5 Replies
6. Shell Programming and Scripting
I have a text file of alphanumeric values listed one by one. I have to convert them to hexadecimal equivalents for each character seperated by ":" in Unix bash shell script. For example, 12345678 has to be converted to 31:32:33:34:35:36:37:38 (10 Replies)
Discussion started by: mathie
10 Replies
7. Shell Programming and Scripting
I have searched and the answers I have found thus far have led me to this point, so I feel I am just about there.
I am trying to convert a column of hexadecimal to decimal values so that I can filter out via grep just the data I want. I was able to pull my original 3 character hex value and... (10 Replies)
Discussion started by: PCGameGuy
10 Replies
8. Shell Programming and Scripting
hi all,
this is my script:
#! /bin/sh
minutes=$( { i2cget -f -y 0 0x51 3; } 2>&1 )
minutes=${minutes:2}
hour=$( { i2cget -f -y 0 0x51 4; } 2>&1 )
hour=${hour:2}
day=$( { i2cget -f -y 0 0x51 5; } 2>&1 )
day=${day:2}
month=$( { i2cget -f -y 0 0x51 7; } 2>&1 )
month=${month:2}
... (6 Replies)
Discussion started by: enaud
6 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I want to convert two hexadecimal numbers to decimal using unix command line.
1cce446295197a9d6352f9f223a9b698
fc8f99ac06e88c4faf669cf366f60d
I tried using
`echo "ibase=16; $no |bc`
printf '%x\n' "1cce446295197a9d6352f9f223a9b698"
but it doesn't work for such big number it... (4 Replies)
Discussion started by: sudhakar T
4 Replies
10. Programming
Hi ,
seq can be 0...128
int windex = seq / 8;
int bindex = seq % 8;
unsigned char bitvalue = '\x01' << (7-bindex) ;
bpv.bitmapvalue = bitvalue;
This is the part of a program to convert decimal to bitmap value of hexadecimal.
I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies
LEARN ABOUT MOJAVE
strptime_l
STRPTIME(3) BSD Library Functions Manual STRPTIME(3)
NAME
strptime, strptime_l -- parse date and time string
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <time.h>
char *
strptime(const char * restrict buf, const char * restrict format, struct tm * restrict timeptr);
#include <time.h>
#include <xlocale.h>
char *
strptime_l(const char * restrict buf, const char * restrict format, struct tm * restrict timeptr, locale_t loc);
DESCRIPTION
The strptime() function parses the string in the buffer buf according to the string pointed to by format, and fills in the elements of the
structure pointed to by timeptr. The resulting values will be relative to the local time zone. Thus, it can be considered the reverse oper-
ation of strftime(3). The strptime_l() function does the same as strptime(), but takes an explicit locale rather than using the current
locale.
The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly
with the buffer, where white space in the format string will match any amount of white space in the buffer. All conversion specifications
are identical to those described in strftime(3).
Two-digit year values, including formats %y and %D, are now interpreted as beginning at 1969 per POSIX requirements. Years 69-00 are inter-
preted in the 20th century (1969-2000), years 01-68 in the 21st century (2001-2068). The %U and %W format specifiers accept any value within
the range 00 to 53.
If the format string does not contain enough conversion specifications to completely specify the resulting struct tm, the unspecified members
of timeptr are left untouched. For example, if format is ``%H:%M:%S'', only tm_hour, tm_sec and tm_min will be modified. If time relative
to today is desired, initialize the timeptr structure with today's date before passing it to strptime().
RETURN VALUES
Upon successful completion, strptime() returns the pointer to the first character in buf that has not been required to satisfy the specified
conversions in format. It returns NULL if one of the conversions failed. strptime_l() returns the same values as strptime().
LEGACY DESCRIPTION
In legacy mode, the %Y format specifier expects exactly 4 digits (leaving any trailing digits for the next specifier).
SEE ALSO
date(1), scanf(3), strftime(3), xlocale(3)
HISTORY
The strptime() function appeared in FreeBSD 3.0.
AUTHORS
The strptime() function has been contributed by Powerdog Industries.
This man page was written by Jorg Wunsch.
BUGS
Both the %e and %l format specifiers may incorrectly scan one too many digits if the intended values comprise only a single digit and that
digit is followed immediately by another digit. Both specifiers accept zero-padded values, even though they are both defined as taking
unpadded values.
The %p format specifier has no effect unless it is parsed after hour-related specifiers. Specifying %l without %p will produce undefined
results. Note that 12AM (ante meridiem) is taken as midnight and 12PM (post meridiem) is taken as noon.
The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". This limitation is because of ambi-
guity due to of the over loading of time zone abbreviations. One such example is EST which is both Eastern Standard Time and Eastern Aus-
tralia Summer Time.
The strptime() function does not correctly handle multibyte characters in the format argument.
BSD
October 2, 2014 BSD