10-11-2011
how to get data from hex file using SED or AWK based on pattern sign
I have a binary (hex) file I need to parse to get some data which are encoded this way:
.* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL
By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in x1-xL bytes (where L1 is number of 'x' data bytes) and value stored in y1-yL (where L2 is number of 'y' data bytes).
Desired data can be identified by this sequence of bytes:
.* b4 . . . 01 12 .* af .* 83
where '.*' means any number of data, '. . .' means 3 bytes, 'B4, 01, 12, af, 83' is unique ordered sequence which identifies 83 L1 x1 - xL 84 L2 y1 - yL data container (the 'y' bytes identificator '84' must follow immediately after x1-xL data).
Yeh! ... somehow complicated to explain, but I hope clear enough. Can anybody help with the script output of which will be 'X' and 'Y' value from the file.
Note: there may be multiple occurence required data in the file with the different values of 'X' and 'Y', but each one occurence of 'X' and 'Y' is preceeded by string identificator .* b4 . . . 01 12 .* af .* 83 as stated above
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
Can someone please help me write a script for the following requirement in awk, grep, sed or perl.
Buuuu xxx bbb
Kmmmm rrr ssss uuuu
Kwwww zzzz ccc
Roooowwww eeee
Bxxxx jjjj dddd
Kuuuu eeeee nnnn
Rpppp cccc vvvv cccc
Rhhhhhhyyyy tttt
Lhhhh rrrrrssssss
Bffff mmmm iiiii
Ktttt... (5 Replies)
Discussion started by: kumarn
5 Replies
2. Shell Programming and Scripting
HI I HAVE A PROBLEM,MY SOURCE FILE IS OF PATTERN
S1,E-Certified,29,29,2.7,Certified,4,3,2.7,,0,0,0
S2,Certified,4,3,2.7,,0,0,0,,0
S3,E-Certified,29,29,2.7,,0,0,0
S4,,0,0,0,,0,0,0,,0,0,0,,0,0,0
AND THE EXPECTED OUTPUT IS
S1,E-Certified,29,29,2.7
S1,Certified,4,3,2.7... (1 Reply)
Discussion started by: pkumar3
1 Replies
3. Shell Programming and Scripting
My input:
File_1:
2000_t
g1110.b1
abb.1
2001_t
g1111.b1
abb.2
abb.2
g1112.b1
abb.3
2002_t
.
.
File_2:
2000_t Ali england 135
abb.1 Zoe british 150
2001_t Ali england 305
g1111.b1 Lucy russia 126 (6 Replies)
Discussion started by: patrick87
6 Replies
4. Shell Programming and Scripting
Hello All,
I am here again scratching my head on pattern selection with special characters.
I have a large file having around 200 entries and i have to select a single line based on a pattern.
I am able to do that:
Code:
cat mytest.txt | awk -F: '/myregex/ { print $2}'
... (6 Replies)
Discussion started by: usha rao
6 Replies
5. Shell Programming and Scripting
Hi,
I would like to delete lines in /etc/hosts on few workstations, basically I want to delete all the lines for a list of machines like this :
for HOST in $(cat stations.lst |uniq)
do
# echo -n "$HOST"
if ping -c 1 $HOST > /dev/null 2>&1
then
HOSTNAME_val=`rsh $HOST "sed... (3 Replies)
Discussion started by: albator1932
3 Replies
6. UNIX for Dummies Questions & Answers
Hello,
:wall:
I have a 12 column csv file. I wish to delete the entire line if column 7 = hello and column 12 = goodbye. I have tried everything that I can find in all of my ref books.
I know this does not work
/^*,*,*,*,*,*,"hello",*,*,*,*,"goodbye"/d
Any ideas?
Thanks
Please... (2 Replies)
Discussion started by: Chris Eagleson
2 Replies
7. Shell Programming and Scripting
I have an input file which is similar to what I have shown below.
Pattern : Data followed by two blank lines followed by data again followed by two blank lines followed by data again etc..
The first three lines after every blank line combination(2 blank lines between data) should be... (2 Replies)
Discussion started by: bikerboy
2 Replies
8. Shell Programming and Scripting
Using the file below, which will always have the first indicated by the digit after the -
and last id in it, indicated by the digit after the -, I am trying to use awk
to print the missing line or lines in file following the pattern of the previous line.
For example, in the file below the next... (4 Replies)
Discussion started by: cmccabe
4 Replies
9. Shell Programming and Scripting
In the awk, thanks you @RavinderSingh13, for the help in below, hopefully it is close as I am trying to update the value in $12 of the tab-delimeted file2 with the matching value in $1 of the space delimeted file1. I have added comments for each line as well. Thank you :).
awk
awk '$12 ==... (10 Replies)
Discussion started by: cmccabe
10 Replies
10. Shell Programming and Scripting
Hi All,
I want to create a new file based on certain conditions and copy only those conditioned data to new file.
Input Data is as it looks below.
ORDER|Header|Add|32|32|1616
ORDER|Details1.........
ORDER|Details2.........
ORDER|Details3.........
ORDER|Details4............ (10 Replies)
Discussion started by: grvk101
10 Replies
LEARN ABOUT DEBIAN
buffer_get
buffer_get(3) Library Functions Manual buffer_get(3)
NAME
buffer_get - read binary data from buffer
SYNTAX
#include <buffer.h>
ssize_t buffer_get(buffer* b,char* x,size_t len);
DESCRIPTION
Normally buffer_get copies data to x[0], x[1], ..., x[len-1] from the beginning of a string stored in preallocated space; removes these len
bytes from the string; and returns len.
If, however, the string has fewer than len (but more than 0) bytes, buffer_get copies only that many bytes, and returns that number.
If the string is empty, buffer_get first uses a read operation to feed data into the string. The read operation may indicate end of input,
in which case buffer_get returns 0; or a read error, in which case buffer_get returns -1, setting errno approporiately.
The preallocated space and the read operation are specified by b. You must initialize b using buffer_init before calling buffer_get (or use
the pre-initialized buffer_0).
SEE ALSO
buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_seek(3), buffer(3)
buffer_get(3)