Sponsored Content
Full Discussion: Grep on a binary file
Top Forums Shell Programming and Scripting Grep on a binary file Post 302454123 by canduc17 on Friday 17th of September 2010 08:20:04 AM
Old 09-17-2010
Code:
user@localhost ~ $ cat binaryFile | sed -n 's/[0-9][0-9]Jan\|Feb\|Mar\|Apr\|Jun\|Jul\|Aug\|Sep\|Oct\|Nov\|Dec\[0-9][0-9]/&/g'
user@localhost ~ $ strings binaryFile | sed -n 's/[0-9][0-9]Jan\|Feb\|Mar\|Apr\|Jun\|Jul\|Aug\|Sep\|Oct\|Nov\|Dec\[0-9][0-9]/&/g'
user@localhost ~ $ strings binaryFile | sed -n 's/[0-9][0-9]Sep[0-9][0-9]/&/g'
user@localhost ~ $

No errors reported, but it doesn't work...
If possible, the simpler way is to use this (which works):
Code:
user@localhost ~ $ strings binaryFile | grep -E "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec" | awk '{ print $21 }'
09Sep09
candini@MEEO-office-007 ~ $

but instead to use "print $21", use a parametric "print $(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)".

But I don't know how to implement something like that...
 

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
DateTime::Locale::en_BE(3)				User Contributed Perl Documentation				DateTime::Locale::en_BE(3)

NAME
DateTime::Locale::en_BE SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'en_BE' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for English Belgium. DATA
This locale inherits from the DateTime::Locale::en locale. It contains the following data. Days Wide (format) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (format) Mon Tue Wed Thu Fri Sat Sun Narrow (format) M T W T F S S Wide (stand-alone) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (stand-alone) Mon Tue Wed Thu Fri Sat Sun Narrow (stand-alone) M T W T F S S Months Wide (format) January February March April May June July August September October November December Abbreviated (format) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (format) J F M A M J J A S O N D Wide (stand-alone) January February March April May June July August September October November December Abbreviated (stand-alone) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (stand-alone) J F M A M J J A S O N D Quarters Wide (format) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide Before Christ Anno Domini Abbreviated BC AD Narrow B A Date Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 1995-12-22T09:05:02 = Friday 22 December 1995 -0010-09-15T04:44:23 = Saturday 15 September -10 Long 2008-02-05T18:30:30 = 5 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Medium 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Time Formats Full 2008-02-05T18:30:30 = 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = Friday 22 December 1995 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = Saturday 15 September -10 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 5 Feb 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Short 2008-02-05T18:30:30 = 05/02/08 18:30 1995-12-22T09:05:02 = 22/12/95 09:05 -0010-09-15T04:44:23 = 15/09/-10 04:44 Default 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Tue 1995-12-22T09:05:02 = 22 Fri -0010-09-15T04:44:23 = 15 Sat Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 PM 1995-12-22T09:05:02 = 9:05 AM -0010-09-15T04:44:23 = 4:44 AM Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 PM 1995-12-22T09:05:02 = 9:05:02 AM -0010-09-15T04:44:23 = 4:44:23 AM M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M/d) 2008-02-05T18:30:30 = 2/5 1995-12-22T09:05:02 = 12/22 -0010-09-15T04:44:23 = 9/15 MEd (E, M/d) 2008-02-05T18:30:30 = Tue, 2/5 1995-12-22T09:05:02 = Fri, 12/22 -0010-09-15T04:44:23 = Sat, 9/15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Feb 1995-12-22T09:05:02 = Dec -0010-09-15T04:44:23 = Sep MMMd (MMM d) 2008-02-05T18:30:30 = Feb 5 1995-12-22T09:05:02 = Dec 22 -0010-09-15T04:44:23 = Sep 15 MMMEd (E, MMM d) 2008-02-05T18:30:30 = Tue, Feb 5 1995-12-22T09:05:02 = Fri, Dec 22 -0010-09-15T04:44:23 = Sat, Sep 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = February 5 1995-12-22T09:05:02 = December 22 -0010-09-15T04:44:23 = September 15 MMMMEd (E, MMMM d) 2008-02-05T18:30:30 = Tue, February 5 1995-12-22T09:05:02 = Fri, December 22 -0010-09-15T04:44:23 = Sat, September 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (M/yyyy) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-010 yMEd (EEE, M/d/yyyy) 2008-02-05T18:30:30 = Tue, 2/5/2008 1995-12-22T09:05:02 = Fri, 12/22/1995 -0010-09-15T04:44:23 = Sat, 9/15/-010 yMMM (MMM y) 2008-02-05T18:30:30 = Feb 2008 1995-12-22T09:05:02 = Dec 1995 -0010-09-15T04:44:23 = Sep -10 yMMMEd (EEE, MMM d, y) 2008-02-05T18:30:30 = Tue, Feb 5, 2008 1995-12-22T09:05:02 = Fri, Dec 22, 1995 -0010-09-15T04:44:23 = Sat, Sep 15, -10 yMMMM (MMMM y) 2008-02-05T18:30:30 = February 2008 1995-12-22T09:05:02 = December 1995 -0010-09-15T04:44:23 = September -10 yQ (Q yyyy) 2008-02-05T18:30:30 = 1 2008 1995-12-22T09:05:02 = 4 1995 -0010-09-15T04:44:23 = 3 -010 yQQQ (QQQ y) 2008-02-05T18:30:30 = Q1 2008 1995-12-22T09:05:02 = Q4 1995 -0010-09-15T04:44:23 = Q3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week Monday SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.3 2014-06-10 DateTime::Locale::en_BE(3)
All times are GMT -4. The time now is 12:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy