Sponsored Content
Full Discussion: Grep on a binary file
Top Forums Shell Programming and Scripting Grep on a binary file Post 302454082 by canduc17 on Friday 17th of September 2010 06:39:04 AM
Old 09-17-2010
Yeah, great!

I'm almost done.

The remaining problem is that this date is on the same line with a lot of other stuff and when I launch your command, the whole line is retrieved.
I obtain only the date with
Code:
strings binaryFile | grep -E "Sep" | awk '{ print $21 }'

because there are only strings, separated by blanks or tabs.

But I have a lot of those file to parse...what if this date is not always at position 21?

Is there a way to generalize it?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

binary file

please let me know how can i mail the binary files is it can be done thru pine? is there any other way to do it? wat are the changes in system i have to make and one more thing i am sending data to a message queue and then retriving the data from the queue but when i do the ipcs... (1 Reply)
Discussion started by: ramneek
1 Replies

2. Solaris

compiled binary file gives "cannot execute binary file"

Hi, I have two Solaris machines. 1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500 2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60 I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies

3. Shell Programming and Scripting

dd - binary file

I have a task that says: make a file (called binaryfile ) that contains 4 bytes of NULL data 6 bytes of random data 8 bytes of 1 10 bytes of 5 and 12 bytes of 9. For the first 2, I can used : dd if=/dev/null of=binaryfile bs=8 count =4 and dd if=/dev/urandom of=binaryfile bs=8... (3 Replies)
Discussion started by: spiriad
3 Replies

4. Programming

Binary file

Hi all I have a C program to write it's output into a textfile which is also created by the program in between. The file that's get created prompt's a message while opening manually that the file is binary and any change in that leads to it's corruption. I have used putc() to write the output... (2 Replies)
Discussion started by: joshighanshyam
2 Replies

5. Shell Programming and Scripting

To log binary file output to a txt file

Hi, I wrote a small script whose function is to execute the postemsg provided if the threshold breaches. I want to log this postemsg messages to a log file. But I am not able to do. Can someone throw some light on how to log the output of this. I am pasting a snippet of that code. ... (2 Replies)
Discussion started by: dbashyam
2 Replies

6. UNIX for Dummies Questions & Answers

Pipe binary file matches grep results to file

I am using grep to match a pattern, but the output is strange. $ grep -r -o "pattern" * Gives me: Binary file foo1 matches Binary file foo2 matches Binary file foo3 matches To find the lines before/after, I then have to use the following on each file: $ strings foo1 | grep -A1 -B1... (0 Replies)
Discussion started by: chipperuga
0 Replies

7. UNIX for Advanced & Expert Users

How to copy a binary file while the file is being written to by another process

Hello, Can I copy a binary file while the file is being written to by another process? Another process (program) “P1” creates and opens (for writing) binary file “ABC” on local disk. Process P1 continuously write into ABC file every couple of seconds, adding 512-byte blocks of data. ABC file... (1 Reply)
Discussion started by: mbuki
1 Replies

8. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

9. UNIX for Dummies Questions & Answers

[AIX] Binary file warning for text file.

Hello guys, We had to move from a DC to another, and we are now facing an "issue" with some text files. Looks like that some of our log files are set as binary: file TuxConnectorURA.20121012 TuxConnectorURA.20121012: data or International Language text less TuxConnectorURA.20121012... (2 Replies)
Discussion started by: EnioMarques
2 Replies

10. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies
Gedcom::Record(3pm)					User Contributed Perl Documentation				       Gedcom::Record(3pm)

NAME
Gedcom::Record - a module to manipulate Gedcom records Version 1.16 - 24th April 2009 SYNOPSIS
use Gedcom::Record; my $record = tag_record("CHIL", 2); my @records = tag_record("CHIL"); my @recs = $record->record("birth"); my @recs = $record->record("birth", "date"); my $rec = $record->record("birth date"); my $rec = $record->record(["birth", 2], "date"); my @recs = $record->get_record("birth"); my $val = $record->get_value; my @vals = $record->get_value("date"); my @vals = $record->get_value("birth", "date"); my $val = $record->get_value("birth date"); my $val = $record->get_value(["birth", 2], "date"); my $rec = $record->add("birth date", "1 Jan 2000"); my $rec = $record->set("birth date", "2 Jan 2000"); $self->parse($record, $grammar); $record->collect_xrefs($callback); my $xref = $record->resolve_xref($record->{value}); my @famc = $record->resolve $record->get_value("FAMC"); $record->resolve_xrefs($callback); $record->unresolve_xrefs($callback); return 0 unless $record->validate_semantics; $record->normalise_dates($format); $record->renumber($args); print $record->summary, " "; $record->delete_record($sub_record); DESCRIPTION
A selection of subroutines to handle records in a gedcom file. Derived from Gedcom::Item. HASH MEMBERS
Some of the more important hash members are: $record->{new_xref} Used by renumber(). $record->{recursed} Used by renumber(). METHODS
tag_record my $record = tag_record("CHIL", 2); my @records = tag_record("CHIL"); Get specific sub-records from the record. This function is identical to Gedcom::Item::get_item(). The arguments are the name of the tag, and optionally the count. In scalar context, returns the sub-record, or undef if it doesn't exist. In array context, returns all sub-records matching the specified tag. record my @recs = $record->record("birth"); my @recs = $record->record("birth", "date"); my $rec = $record->record("birth date"); my $rec = $record->record(["birth", 2], "date"); my @recs = $record->get_record("birth"); Retrieve a record. The get_record() function is identical to the record() function. In scalar context, record() returns the specified record, or undef if there is none. In list context, record() returns all the specified records. Records may be specified by a list of strings. Each string is either a Gedcom tag or a description. Starting from the first string in the list, specified records are retrieved. Then from those records, records specified by the next string in the list are retrieved. This continues until all strings from the list have been used. In list context, all specified records are retrieved. In scalar context, only the first record is retrieved. If a record other than the first is wanted, then instead of passing a string, a reference to an array containing the string and a count may be passed. Instead of specifying a list of strings, it is possible to specify a single space separated string. This can make the interface nicer. get_value my $val = $record->get_value; my @vals = $record->get_value("date"); my @vals = $record->get_value("birth", "date"); my $val = $record->get_value("birth date"); my $val = $record->get_value(["birth", 2], "date"); Retrieve a record's value. If arguments are specified, record() is first called with those arguments, and the values of those records are returned. add my $rec = $record->add("birth date", "1 Jan 2000"); Add a new record. Add a new record ($rec) as a sub-item of $record. Set its value to the last argument given. The first arguments may be specified as for record(). A new record will always be created for the last argument, and for any arguments for which the count is explicitly set to zero. If the new record does not take a value then do not supply one. This does mean that you cannot use the function with many arguments if the last one is a scalar, but not a value. In this case either specify the last argument as ["arg", 0], or add undef as the last argument. set my $rec = $record->set("birth date", "2 Jan 2000"); Set the value of a record. This is the same as add(), with the exception that a new record is not created for the last argument. parse $self->parse($record, $grammar); Parse a Gedcom record. Match a Gedcom::Record against a Gedcom::Grammar. Warn of any mismatches, and associate the Gedcom::Grammar with the Gedcom::Record as $record->{grammar}. Do this recursively. collect_xrefs $record->collect_xrefs($callback); Recursively collect all the xrefs. Called by Gedcom::collect_xrefs. $callback is not used yet. resolve_xref my $xref = $record->resolve_xref($value); See Gedcom::resolve_xrefs() resolve my @famc = $record->resolve $record->tag_value("FAMC"); For each argument, either return it or, if it an xref, return the referenced record. resolve_xrefs $record->resolve_xrefs($callback); See Gedcom::resolve_xrefs() unresolve_xrefs $record->unresolve_xrefs($callback); See Gedcom::unresolve_xrefs() validate_semantics return 0 unless $record->validate_semantics; Validate the semantics of the Gedcom::Record. This performs a number of consistency checks, but could do even more. Returns true iff the Record is valid. normalise_dates $record->normalise_dates($format); Change the format of all dates in the record. See the documentation for Gedcom::normalise_dates renumber $record->renumber($args); Renumber the record. See Gedcom::renumber(). child_value NOTE - This function is deprecated - use tag_value instead. my $child = $record->child_value("NAME"); child_values NOTE - This function is deprecated - use tag_value instead. my @children = $record->child_values("CHIL"); summary print $record->summary, " "; Return a line of text summarising the record. delete_record $record->delete_record($sub_record); Delete the specified sub-record from the record. Access functions All the Gedcom tag names can be used as function names. Depending on the context in which they are called, the functions return either an array of the specified sub-items, or the first specified sub-item. The descriptions of the tags, with spaces replaced by underscores, can also be used as function names. The function names can be of either, or mixed case. Unless you use the tag name, in either case, or the description in lower case, the function will not be pre- declared and you will need to qualify it or "use subs". perl v5.14.2 2012-04-12 Gedcom::Record(3pm)
All times are GMT -4. The time now is 06:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy