473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

To grep a file within a time range using PERL

I work in an investment bank. We have a huge log file which contains FIX messages. I have a problem to grep FIX messages within a time rage (i.e. between 9:30 am to 11 pm, those were sent by CITIBANK for ticker symbol MSFT). I tried different ways but it did not work. Could anyone please help me?

Here is one of the codes in perl:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl –w
  2.  
  3. $myfile = “/tmp/fixlog.txt”;
  4. open(FH, $myfile) || die “Can not open”;
  5. while<FH>{
  6.     chomp;
  7. print “$_\n” if (m/CITIBANK/ | /MSFT/  | /20071115-09:30:00 ~ 20071115-11:00:00/);
  8. close(FH);
Here is a code in grep:

Expand|Select|Wrap|Line Numbers
  1.   grep ‘/CITIBANK/’ | ‘/MSFT/’ | ‘/20071115-09:30:00 ~ 20071115-11:00:00/’ fixlog
Nov 16 '07 #1
4 5684
KevinADC
4,059 Expert 2GB
Your grep code is not perl. How is the data file formatted?
Nov 16 '07 #2
Your grep code is not perl. How is the data file formatted?
My grep code is unix command line code.

The data file is raw log file. (FIX messages).
Exactly like this:
8=FIX.4.29=7435=A49=AXESNET56=ATLAFM34=143=N 97=N52=20071101-06:01:3798=0108=6010=237ATLAFM AXESNET 0  _ 8=FIX.4.29=7335=049=AXESNET56=ATLAFM34=243=N 97=N52=20071101-06:01:37112=07013610=195ATLAFM AXESNET 0  T 8=FIX.4.29=6235=049=AXESNET56=ATLAFM34=343=N 97=N52=20071101-06:02:3810=193ATLAFM
Nov 16 '07 #3
Can you provide the line you want to match so that someone can provide you with the regex you can use
Nov 17 '07 #4
Can you provide the line you want to match so that someone can provide you with the regex you can use
I need to get the part of the log file within the following time range using regular expression:

(/20071115-09:30:00 ~ 20071115-11:00:00/);
Nov 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John E. Jardine | last post by:
Hi, Problem: Executing 's///' has a side effect on grep null string matching. If line 62, the substitution, is executed the last two values returned by grep and printed on lines 68, 69 are...
1
by: Al Belden | last post by:
Hi all, I've been working on a problem that I thought might be of interest: I'm trying to replace some korn shell scripts that search source code files with perl scripts to gain certain features...
9
by: Adam Monsen | last post by:
I kindly request a code review. If this is not an appropriate place for my request, where might be? Specific questions are in the QUESTIONS section of the code. ...
4
by: js | last post by:
Just my curiosity. Can python beats perl at speed of grep-like processing? $ wget http://www.gutenberg.org/files/7999/7999-h.zip $ unzip 7999-h.zip $ cd 7999-h $ cat *.htm bigfile $ du -h...
15
by: tereglow | last post by:
Hello all, I come from a shell/perl background and have just to learn python. To start with, I'm trying to obtain system information from a Linux server using the /proc FS. For example, in...
2
by: ravir | last post by:
Hi, I am new to this group. I am working in Perl and shellscripts. I have a clarification regarding perl grep and pattern matching. I am writing a perl script to automate the process of code...
47
by: Henning_Thornblad | last post by:
What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row="" for a in range(156000):...
6
by: kronus | last post by:
Hi everyone, This is my first time posting to the UNIX form and it might be a strange request, but I believe I have most of the pieces. Here's the overall goal -- I am trying to find the links...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.