Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Need to convert bytearray into text2pcap format Post 303036540 by sand1234 on Monday 1st of July 2019 09:14:55 PM
Old 07-01-2019
Hi RudiC,

That works perfectly.

Code:
awk '{printf "%04x %s\n", counter, $0; counter += NF}' capture.txt

From what I understand, %04x pads the first element with 0s to make up 4 digits in hex, and is assigned to variable counter. After this, we print the rest of the line as a string.

However I cannot understand why we need counter+=NF in this case, as NF should be 16. Can you please explain this logic? Can we use something else to accomplish this (i.e for loop).

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert mmddyy date format to ccyyddd format??

hi, for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format. i checked the datecalc and other scripts but couldnt modify them to cater to my need:(... The datecalc gives an output which i believe is the total days till that date, but i want to convert it... (2 Replies)
Discussion started by: Bhups
2 Replies

2. UNIX for Advanced & Expert Users

Convert UTF8 Format file to ANSI format

:) Hi i am trying to convert a file which is in UTF8 format to ANSI format i tried to use the function ICONV but it is throwing error Function i used it as $ iconv -f UTF8 -t ANSI filename Error iam getting is NOT Supported UTF8 to ANSI please some help me out on this.........Let me... (1 Reply)
Discussion started by: rajreddy
1 Replies

3. UNIX for Dummies Questions & Answers

Convert UTF8 Format file to ANSI format

:confused: Hi i am trying to convert a file which is in UTF8 format to ANSI format i tried to use the function ICONV but it is throwing error Function i used it as $ iconv -f UTF8 -t ANSI filename Error iam getting is NOT Supported UTF8 to ANSI please some help me out on... (9 Replies)
Discussion started by: rajreddy
9 Replies

4. UNIX for Dummies Questions & Answers

To convert multi format file to a readable ascii format

Hi I have a file which has ascii , binary, binary decimal coded,decimal & hexadecimal data with lot of special characters (like öƒ.ƒ.„İİ¡Š·œƒ.„İİ¡Š· ) in it. I want to standardize the file into ASCII format & later use that as source . Can any one suggest a way a logic to convert such... (5 Replies)
Discussion started by: gaur.deepti
5 Replies

5. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

6. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

7. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

8. UNIX for Dummies Questions & Answers

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (1 Reply)
Discussion started by: Samtel
1 Replies

9. Shell Programming and Scripting

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (2 Replies)
Discussion started by: Samtel
2 Replies

10. Shell Programming and Scripting

perl module to convert xlsx format to xls format

Hi Folks, I have written a perl script that reads data from excel sheet(.xls) using Spreadsheet::ParseExcel module. But the problem is this module doesn't work for excel sheets with extension .xlsx. I have gone through Spreadsheet::XLSX module with which we can read from .xlsx file directly.... (1 Reply)
Discussion started by: giridhar276
1 Replies
cpc_npic(3CPC)					    CPU Performance Counters Library Functions					    cpc_npic(3CPC)

NAME
cpc_npic, cpc_caps, cpc_cciname, cpc_cpuref, cpc_walk_events_all, cpc_walk_events_pic, cpc_walk_attrs - determine CPU performance counter configuration SYNOPSIS
cc [ flag... ] file... -lcpc [ library... ] #include <libcpc.h> const char *cpc_cciname(cpc_t *cpc); const char *cpc_cpuref(cpc_t *cpc); uint_t cpc_npic(cpc_t *cpc); uint_t cpc_caps(cpc_t *cpc); void cpc_walk_events_all(cpc_t *cpc, void *arg, void (*action)(void *arg, const char *event)); void cpc_walk_events_pic(cpc_t *cpc, uint_t picno, void *arg, void (*action)(void *arg, uint_t picno, const char *event)); void cpc_walk_attrs(cpc_t *cpc, void *arg, void (*action)(void *arg, const char *attr)); DESCRIPTION
The cpc_cciname() function returns a printable description of the processor performance counter interfaces, for example, the string Ultra- SPARC III+ & IV. This name should not be assumed to be the same as the name the manufacturer might otherwise ascribe to the processor. It simply names the performance counter interfaces as understood by the system, and thus names the set of performance counter events that can be described by that interface. The cpc_cpuref() function returns a string that describes a reference work that should be consulted to (allow a human to) understand the semantics of the performance counter events that are known to the system. The string returned might be substantially longer than 80 charac- ters. Callers printing to a terminal might want to insert line breaks as appropriate. The cpc_npic() function returns the number of performance counters accessible on the processor. The cpc_caps() function returns a bitmap containing the bitwise inclusive-OR of zero or more flags that describe the capabilities of the processor. If CPC_CAP_OVERFLOW_INTERRUPT is present, the processor can generate an interrupt when a hardware performance counter overflows. If CPC_CAP_OVERFLOW_PRECISE is present, the processor can determine precisely which counter overflowed, thereby affecting the behavior of the overflow notification mechanism described in cpc_bind_curlwp(3CPC). The system maintains a list of performance counter events supported by the underlying processor. Some processors are able to count all events on all hardware counters, while other processors restrict certain events to be counted only on specific hardware counters. The sys- tem also maintains a list of processor-specific attributes that can be used for advanced configuration of the performance counter hardware. These functions allow applications to determine what events and attributes are supported by the underlying processor. The reference work pointed to by cpc_cpuref() should be consulted to understand the reasons for and use of the attributes. The cpc_walk_events_all() function calls the action function on each element of a global event list. The action function is called with each event supported by the processor, regardless of which counter is capable of counting it. The action function is called only once for each event, even if that event can be counted on more than one counter. The cpc_walk_events_pic() function calls the action function with each event supported by the counter indicated by the picno argument, where picno ranges from 0 to the value returned by cpc_npic(). The system maintains a list of attributes that can be used to enable advanced features of the performance counters on the underlying pro- cessor. The cpc_walk_attrs() function calls the action function for each supported attribute name. See the reference material as returned by cpc_cpuref(3CPC) for the semantics use of attributes. RETURN VALUES
The cpc_cciname() function always returns a printable description of the processor performance counter interfaces. The cpc_cpuref() function always returns a string that describes a reference work. The cpc_npic() function always returns the number of performance counters accessible on the processor. The cpc_caps() function always returns a bitmap containing the bitwise inclusive-OR of zero or more flags that describe the capabilities of the processor. If the user-defined function specified by action is not called, the cpc_walk_events_all(), cpc_walk_events_pic(), and cpc_walk_attrs() functions set errno to indicate the error. ERRORS
The cpc_walk_events_all(), cpc_walk_events_pic(), and cpc_walk_attrs() functions will fail if: ENOMEM There is not enough memory available. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
cpc_bind_curlwp(3CPC), libcpc(3LIB), attributes(5) SunOS 5.10 30 Jan 2004 cpc_npic(3CPC)
All times are GMT -4. The time now is 06:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy