Sponsored Content
Top Forums Shell Programming and Scripting printing format for hexadecimal signed number Post 302144032 by aigles on Tuesday 6th of November 2007 02:58:35 AM
Old 11-06-2007
There is no format in awk that permits to get only the last three last digit.
But you can write your own function, for example :

Code:
function toHexa(number, len      ,str) {
   if (len == 0) len = 2;
   str = sprintf("%0" len "." len "x", number);
   return substr(str, length(str)-len+1) "";
}
{
   print $1, "=>", toHexa($1,3);
}

Input:
Code:
0
1
27
3210
-1
-30

Output:
Code:
0 => 000
1 => 001
27 => 01b
3210 => c8a
-1 => fff
-30 => fe2

Jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need script to convert number in hexadecimal

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

2. Shell Programming and Scripting

Test Hexadecimal number

Hi, I would like test if a number (with 2 digit, for example a9 , 0b ) is a hexadecimal number with 2 digit ? (2 Replies)
Discussion started by: francis_tom
2 Replies

3. HP-UX

Editing a UNIX file in Hexadecimal format

Hi, I am a newbie to the UNIX world. I am asked to edit the file in hexadecimal format and save it. Later I should be able to print the file in char mode. please anyone tell me how to do that mostly using VI editor. (1 Reply)
Discussion started by: vkudire
1 Replies

4. UNIX for Advanced & Expert Users

"Signed Linux" - Only executing signed programs

Hey folks, not sure whether this or the security board is the right forum. If I failed, please move :) So here's the problem: I need to build a Linux environment in which only "signed" processes are allowed to run. When I say signed I don't mean a VeriSign signature like you know it from... (5 Replies)
Discussion started by: disaster
5 Replies

5. Shell Programming and Scripting

Printing Number of Fields with the line number

Hi, How to print the number of fields in each record with the line number? Lets saw I have 3212|shipped|received| 3213|shipped|undelivered| 3214|shipped|received|delivered I tried the code awk -F '|' '{print NF}' This gives me ouput as 3 3 4 (5 Replies)
Discussion started by: machomaddy
5 Replies

6. UNIX for Dummies Questions & Answers

Printing records in different format

Hi all, I have a input file say record.txt hostname IP_address Port_No Version A 10.10.10.1 80 6.02 B 10.10.10.2 81 6.03 C 10.10.10.3 82 6.04 row 1 has 4 field headings : hostname, IP_address, Port_No and Version. and from 2nd row onwards the actual records start. now i need to... (2 Replies)
Discussion started by: PranavEcstasy
2 Replies

7. UNIX for Dummies Questions & Answers

Help with printing output format from a file

Hi, I need help in printing data in below format from file extensions with .dml, i have listed details below file name is test_temp.dml, location in /home/users/test01/test_temp.dml file content: sample_type= record decimal(",") test_type; date("DD-MM-YYYY")(",") test_date... (2 Replies)
Discussion started by: AAHinka
2 Replies

8. UNIX for Dummies Questions & Answers

Printing files in a specific format

Hi, I have following files in a directory with '.meta' extension, which have data in follwoing patterns. i need to print data from these files in below metioned format. please provide a script for this solution. file names: TEST_HISTORY_MTH.meta AB_TEST_1.meta cat... (2 Replies)
Discussion started by: AAHinka
2 Replies

9. Shell Programming and Scripting

Help required in printing in specific format

Hi All, I 'm matching two files based on the first 2 columns and then populate other fields along with subtraction of few fields. I have managed to get the output. However, is there a easier way in formatting the output as shown below instead of using additional printf for getting fixed width... (4 Replies)
Discussion started by: shash
4 Replies

10. UNIX for Beginners Questions & Answers

Printing df -h output in json format

Hi All, i am trying to print the df -h ouput in json format. using below script. #!/usr/bin/env bash df -h > /tmp/sdf nawk '{print " "$1" "$2" "$3" "$4" "$5" "$6" "}' /tmp/sdf > /tmp/sdf1 nawk 'NR==1 { for (i=1; i<=NF; i++) { f = i }}{ print $(f), $(f), $(f), $(f), ... (2 Replies)
Discussion started by: sravani25
2 Replies
stringprep_ucs4_nfkc_normalize(3)				      libidn					 stringprep_ucs4_nfkc_normalize(3)

NAME
stringprep_ucs4_nfkc_normalize - API function SYNOPSIS
#include <stringprep.h> uint32_t * stringprep_ucs4_nfkc_normalize(const uint32_t * str, ssize_t len); ARGUMENTS
const uint32_t * str a Unicode string. ssize_t len length of str array, or -1 if str is nul-terminated. DESCRIPTION
Converts a UCS4 string into canonical form, see stringprep_utf8_nfkc_normalize() for more information. RETURN VALUE
a newly allocated Unicode string, that is the NFKC normalized form of str. REPORTING BUGS
Report bugs to <bug-libidn@gnu.org>. GNU Libidn home page: http://www.gnu.org/software/libidn/ General help using GNU software: http://www.gnu.org/gethelp/ COPYRIGHT
Copyright (C) 2002-2013 Simon Josefsson. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. SEE ALSO
The full documentation for libidn is maintained as a Texinfo manual. If the info and libidn programs are properly installed at your site, the command info libidn should give you access to the complete manual. libidn 1.28 stringprep_ucs4_nfkc_normalize(3)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy