Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Pull out multiple lines with grep patternfile Post 302784785 by FGPonce on Saturday 23rd of March 2013 04:47:18 AM
Old 03-23-2013
Pull out multiple lines with grep patternfile

Hi,
I'm trying to get lines from a file using identifiers in the first two columns. I have used:

cat MasterFile.txt | grep -f Pattern.txt

and the lines I want display on screen. If I try to put them in a file the file is created but stays empty:

cat MasterFile.txt | grep -f Pattern.txt > output.txt

Also: If I use the whole pattern file (tested with 12 top lines from my pattern file to start) it doesn't even display on screen.....

Any ideas how I can do this? Very frustrating that the process seems to work but then hit the brick wall!!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep on multiple lines

I 'm trying to grep 2 fieldds on 2 differnt lines. Like this: psit > file egrep -e '(NS|ES)' $file. Not working. If this succeeds then run next cmd else exit. Pls Help Gundu (13 Replies)
Discussion started by: gundu
13 Replies

2. Shell Programming and Scripting

grep multiple lines

Hey guys: I've been meaning to post this question for awhile...it is regarding grep. Let's say for example that the following entry is in logxx: Wed Feb 2 07:44:11 <vsm> 91030 Line 5 Severity 1 Vps 6 Call Answered - DN:8753101 CLID:5164665761 PI:83 If I do a grep 91030... (27 Replies)
Discussion started by: cdunavent
27 Replies

3. Shell Programming and Scripting

grep multiple lines

Hi. I have this format on a textfile: VG Name /dev/vg00 PV Name /dev/dsk/c16t0d0 PV Name /dev/dsk/c18t0d0 PV Name /dev/dsk/c16t4d0 VG Name /dev/vg01 PV Name ... (6 Replies)
Discussion started by: jOOc
6 Replies

4. Shell Programming and Scripting

How do you use pull data from multiple lines to do a for statement?

Guys I am having a problem with being able to find missing monitors in a configuration check script I am trying to create for accountability purposes for managing a large number of systems. What I am trying to do is run a script that will look at the raw config data in a file and pull all the pool... (7 Replies)
Discussion started by: scottzx7rr
7 Replies

5. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

6. UNIX for Dummies Questions & Answers

grep in multiple lines

hi i have kind of below text in a file. I want to get a complete paragraph starting with START and ending with before another START) which has a particular string say XYZ or ABC START XYZ hshjghkjh 45 ljkfd fldjlj d jldf START 3493u ABC 454 4545454 4545454 45454 4545454 START ...... (3 Replies)
Discussion started by: reldb
3 Replies

7. UNIX for Advanced & Expert Users

grep across multiple lines

How do you grep 'select * from table_name' string from a script if the select * and from table_name are on 2 different lines ? like select * from table_name Any help would be greatly appreciated !!! Thanks RDR (4 Replies)
Discussion started by: RDR
4 Replies

8. UNIX for Dummies Questions & Answers

grep first occurrence but continue to next entry in patternfile

I have 1300 files (SearchFiles0001.txt, SearchFiles0002.txt, etc.) , each with 650,000 lines, tab-delimited data. I have a pattern file, with about 1000 lines with a single word. Each single word is found in the 1300 files once. If I grep -f PatternFile.txt SearchFiles*.txt >OutputFile.txt... (2 Replies)
Discussion started by: newhavendweeb
2 Replies

9. UNIX for Dummies Questions & Answers

Grep multiple lines

I want to grep multiple lines from a text file. I want to grep all lines containing X,Y and NA in a single command. How do I go about doing that? This is what my text files look like: rs1983866 0.0983 10 100016313 rs1983865 0.5994 X 100016339 rs1983864 0.3272 11 100017453 rs7077266... (2 Replies)
Discussion started by: evelibertine
2 Replies

10. Shell Programming and Scripting

How do I use grep to pull incremental data and send to multiple files?

Hi Everyone, Im currently using the below code to pull data from a large CSV file and put it into smaller files with just the data associated with the number that I "grep". grep 'M053' test.csv > test053.csv Is there a way that I can use grep to run through my file like the example below... (6 Replies)
Discussion started by: TheStruggle
6 Replies
EXIMSTATS(8)							       EXIM4							      EXIMSTATS(8)

NAME
eximstats - generates statistics from Exim mainlog or syslog files. SYNOPSIS
eximstats [Output] [Options] mainlog1 mainlog2 ... eximstats -merge [Options] report.1.txt report.2.txt ... > weekly_report.txt Output: -txt Output the results in plain text to STDOUT. -txt=filename Output the results in plain text. Filename '-' for STDOUT is accepted. -html Output the results in HTML to STDOUT. -html=filename Output the results in HTML. Filename '-' for STDOUT is accepted. -xls Output the results in Excel compatible Format to STDOUT. Requires the Spreadsheet::WriteExcel CPAN module. -xls=filename Output the results in Excel compatible format. Filename '-' for STDOUT is accepted. Options: -hnumber histogram divisions per hour. The default is 1, and 0 suppresses histograms. Valid values are: 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60. -ne Don't display error information. -nr Don't display relaying information. -nr/pattern/ Don't display relaying information that matches. -nt Don't display transport information. -nt/pattern/ Don't display transport information that matches -qlist List of times for queuing information single 0 item suppresses. -tnumber Display top <number> sources/destinations default is 50, 0 suppresses top listing. -tnl Omit local sources/destinations in top listing. -t_remote_users Include remote users in the top source/destination listings. -include_original_destination Include the original destination email addresses rather than just using the final ones. Useful for finding out which of your mailing lists are receiving mail. -show_dtlist Show the delivery times (DT)for all the messages. Exim must have been configured to use the +deliver_time logging option for this option to work. list is an optional list of times. Eg -show_dt1,2,4,8 will show the number of messages with delivery times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -show_rtlist Show the receipt times for all the messages. The receipt time is defined as the Completed hh:mm:ss - queue_time_overall - the Receipt hh:mm:ss. These figures will be skewed by pipelined messages so might not be that useful. Exim must have been configured to use the +queue_time_overall logging option for this option to work. list is an optional list of times. Eg -show_rt1,2,4,8 will show the number of messages with receipt times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -byhost Show results by sending host. This may be combined with -bydomain and/or -byemail and/or -byedomain. If none of these options are specified, then -byhost is assumed as a default. -bydomain Show results by sending domain. May be combined with -byhost and/or -byemail and/or -byedomain. -byemail Show results by sender's email address. May be combined with -byhost and/or -bydomain and/or -byedomain. -byemaildomain or -byedomain Show results by sender's email domain. May be combined with -byhost and/or -bydomain and/or -byemail. -pattern Description /Pattern/ Look for the specified pattern and count the number of lines in which it appears. This option can be specified multiple times. Eg: -pattern 'Refused connections' '/refused connection/' -merge This option allows eximstats to merge old eximstat reports together. Eg: eximstats mainlog.sun > report.sun.txt eximstats mainlog.mon > report.mon.txt eximstats mainlog.tue > report.tue.txt eximstats mainlog.wed > report.web.txt eximstats mainlog.thu > report.thu.txt eximstats mainlog.fri > report.fri.txt eximstats mainlog.sat > report.sat.txt eximstats -merge report.*.txt > weekly_report.txt eximstats -merge -html report.*.txt > weekly_report.html o You can merge text or html reports and output the results as text or html. o You can use all the normal eximstat output options, but only data included in the original reports can be shown! o When merging reports, some loss of accuracy may occur in the top n lists. This will be towards the ends of the lists. o The order of items in the top n lists may vary when the data volumes round to the same value. -charts Create graphical charts to be displayed in HTML output. Only valid in combination with -html. This requires the following modules which can be obtained from http://www.cpan.org/modules/01modules.index.html GD GDTextUtil GDGraph To install these, download and unpack them, then use the normal perl installation procedure: perl Makefile.PL make make test make install On Debian GNU/Linux you can use "apt-get install libgd-perl libgd-text-perl libgd-graph-perl" instead. -chartdirI <dir> Create the charts in the directory <dir> -chartrelI <dir> Specify the relative directory for the "img src=" tags from where to include the charts -emptyok Specify that it's OK to not find any valid log lines. Without this we will output an error message if we don't find any. -d Debug flag. This outputs the eval()'d parser onto STDOUT which makes it easier to trap errors in the eval section. Remember to add 1 to the line numbers to allow for the title! DESCRIPTION
Eximstats parses exim mainlog and syslog files to output a statistical analysis of the messages processed. By default, a text analysis is generated, but you can request other output formats using flags. See the help (-help) to learn about how to create charts from the tables. AUTHOR
There is a web site at http://www.exim.org TO DO
This program does not perfectly handle messages whose received and delivered log lines are in different files, which can happen when you have multiple mail servers and a message cannot be immediately delivered. Fixing this could be tricky... Merging of xls files is not (yet) possible. Be free to implement :) perl v5.14.2 2014-07-24 EXIMSTATS(8)
All times are GMT -4. The time now is 05:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy