Finding the same pattern in three consecutive lines in several files in a directory
I know how to search for a pattern/regular expression in many files that I have in a directory. For example, by doing this:
I can find which files contain the pattern "News/U.S." in a directory.
I am unable to accomplish about how to extend this code so that it can search for 3 consecutive lines in the files which contain the above pattern. The code should only output file names which contain three consecutive times the above pattern, and disregard less than 2 or 4 or greater.
I mean:
As you can see News/U.S. appears 3 times consecutively in newlines. I want to output those file names which contain the above pattern. I am using Linux with BASH.
Hi,
I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern.
Note:These are the samples of two files,but i can have more... (2 Replies)
How to get (a list of) all the text files in the current directory and subdirectories which has the following two consecutive lines:
ctrl_end_date=2009
ctrl_process=EXPIRED
OR
ctrl_end_date=2010
ctrl_process=EXPIRED
i.e.
(ctrl_end_date=2009 OR ctrl_end_date=2010)
AND
ctrl_process=EXPIRED... (6 Replies)
Hi,
I am trying to locate the occurences of certain pattern like 'Possible network disconnect' in a text file. I can get the actual lines matching the pttern using:
grep -w 'Possible network disconnect' file_name.
But I am more interested in getting the timing of these events which are... (7 Replies)
Hi ,
I'm looking for a way to merge two lines only for a given pattern / condition.
Input :
abcd/dad + -49.201 2.09 -49.5 34 ewrew rewtre *
fdsgfds/dsgf/sdfdsfasdd +
-4.30 0.62 -49.5 45 sdfdsf cvbbv *
sdfds/retret/asdsaddsa +
... (1 Reply)
I have following pattern in a file:
00:01:38 UTC
abcd
00:01:48 UTC
00:01:58 UTC
efgh
00:02:08 UTC
00:02:18 UTC
and I need to change something like the following
00:01:38 UTC
abcd
00:01:48 UTC
XXXX
00:01:58 UTC
efgh
00:02:08 UTC
XXXX (6 Replies)
I have a file with the following contents.
DTP
START
START
START
DTP
START
DTP
START
DTP
START
I like to join the lines like this
DTP START
START
START
DTP START
DTP START (2 Replies)
Hi,
I would like to know how to remove lines which has the same pattern as the next line through sed/awk.
Stream 39 (wan stream 7)
Stream 40 (wan stream 8)
WINQ Counter 115955 1 1613
(BYTE) 11204787 163 ... (2 Replies)
I need to find the latest file -filename_YYYYMMDD in the directory DIR. the below is not working as the position is shifting each time because of the spaces between(occuring mostly at file size field as it differs every time.)
please suggest if there is other way.
report =‘ls -ltr... (2 Replies)
I have a text file with many thousands of lines, a small sample of which looks like this:
InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0
PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
I have a file like below.
2018.07.01, Sunday
09:27 some text 123456789 0 21 0.06 0.07 0.00
2018.07.02, Monday
09:31 some text 123456789 1 41 0.26 0.32 0.00
09:39 some text 456789012 1 0.07 0.09 0.09
09:45 some text 932469494 1 55 0.29 0.36 0.00
16:49 some text 123456789 0 48 0.12 0.15 0.00... (9 Replies)
Discussion started by: father_7
9 Replies
LEARN ABOUT DEBIAN
news::scan::article
News::Scan::Article(3pm) User Contributed Perl Documentation News::Scan::Article(3pm)NAME
News::Scan::Article - collect information about news articles
SYNOPSIS
use News::Scan::Article;
my $art = News::Scan::Article->new( ARG, [ OPTIONS, ] SCAN );
DESCRIPTION
This module provides a derived class of "Mail::Internet" whose objects are suitable for digesting Usenet news articles.
CONSTRUCTOR
new ( ARG, [ OPTIONS, ] SCAN-OBJ )
The "ARG" and "OPTIONS" parameters are identical to those required by "Mail::Internet", except "ARG" is required. See Mail::Internet.
The "SCAN" parameter should be a "News::Scan" object. See News::Scan.
If the article falls into the period of interest for "SCAN", the object is returned, else "undef".
METHODS
group ( [ SCAN-OBJ ] )
Sets or returns an object's group depending on whether "SCAN-OBJ" is present.
author
Returns the article's author represented as a "Mail::Address" object.
message_id
Returns the article's Message-ID.
subject
Returns the article's subject.
newsgroups
Returns the list of newsgroups this article was posted to.
size
Returns the size of this article in bytes.
header_size
Returns the size of this article's header in bytes.
header_lines
Returns the number of lines consumed in this article by headers.
body_size
Returns the size of this article's body in bytes.
body_lines
Returns the number of lines consumed in this article by the body.
orig_size
Returns the size of this article's original content in bytes. See "QuoteRE" in News::Scan.
orig_lines
Returns the number of lines consumed in this article by original content. Keep in mind that original content is a subset of the body.
sig_size
Returns the size of this article'ss signature in bytes.
sig_lines
Returns the number of lines consumed in this article by the signature.
SEE ALSO
News::Scan, Mail::Internet, Mail::Address
AUTHOR
Greg Bacon <gbacon@cs.uah.edu>
COPYRIGHT
Copyright (c) 1997 Greg Bacon. All Rights Reserved. This library is free software. You may distribute and/or modify it under the same
terms as Perl itself.
perl v5.10.1 2000-08-09 News::Scan::Article(3pm)