473,756 Members | 3,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To grep a file within a time range using PERL

3 New Member
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 5707
KevinADC
4,059 Recognized Expert Specialist
Your grep code is not perl. How is the data file formatted?
Nov 16 '07 #2
hassan470
3 New Member
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=74 35=A49=AXESNET 56=ATLAFM34=1 43=N97=N52=2 0071101-06:01:3798=01 08=6010=237AT LAFM AXESNET 0  _ 8=FIX.4.29=73 35=049=AXESNET 56=ATLAFM34=2 43=N97=N52=2 0071101-06:01:37112=07 013610=195ATL AFM AXESNET 0  T 8=FIX.4.29=62 35=049=AXESNET 56=ATLAFM34=3 43=N97=N52=2 0071101-06:02:3810=193 ATLAFM
Nov 16 '07 #3
NexisPerl
3 New Member
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
hassan470
3 New Member
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
2685
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 different than the values returned and printed when line 62 is commented out. Line 62 shouldn't have any impact on lines 67,68 & 69. Environment:
1
17721
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 such as: More powerful regular expressions available in perl Ability to print out lines before and after matches (gnu grep supports this but is not availble on our Digital Unix and AIX platforms) Make searches case insensitive by default (yes, I...
9
1712
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. ========================================================================== #include <stdio.h> #include <stdlib.h> #include <string.h>
4
4868
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 bigfile du -h bigfile
15
8222
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 order to obtain the amount of physical memory on the server, I would do the following in shell: grep ^MemTotal /proc/meminfo | awk '{print $2}' That would get me the exact number that I need. Now, I'm trying to do
2
2923
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 review upto some level so that the reviewer and developer's time can be reduced during the code review. In my script, I am using pattern matching and grep in many places. So, my clarification is : Is it fine to make use of grep to find a pattern in a...
47
3443
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): row+="a"
6
8994
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 in a large web site that are linked to files over 2000k. I used the command line to find all files on the server that are larger than 2000k by using the following: find ./ -size +2000c > files_over_2000_bytes.txt
0
10032
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.