Questions tagged [pcregrep]

pcregrep searches files for character patterns, in the same way as other grep commands do, but it uses the PCRE regular expression library to support patterns that are compatible with the regular expressions of Perl 5.

Filter by
Sorted by
Tagged with
0
votes
1answer
38 views

How does pcregrep works?

I have a file: This error -this -this -that [text I want] This error -asd -asfag -adsfhs [text I want] [text I want] This error -asdgsda -asdgg -gasdg I want to match to match except This error and ...
0
votes
1answer
35 views

match groups with an inverted match

I need to extract with -o1 a group that is matched in lines that do not contain a string. If I use -v pcregrep does not match any groups - which is reasonable: I'm asking to group-match something in ...
0
votes
3answers
217 views

find text in files and copy to a csv

I need to extract the text in a bunch of html files (about 500K of them) The text to be copied looks like <div class='cls '>text to be copied including some<span>and <p></p><...
0
votes
4answers
71 views

Select lines based on lines above them

I have a list of items, from which I want to select the names of active items: item { status: "Active" properties { key_a: value } id: 42 name: "Foo" } item { status: "Disabled" ...
3
votes
1answer
232 views

pcregrep to find lines with surrounding white space [closed]

I have some titles that start with # (as they are markdown), and I have the two following rules: titles (#) should have exactly two newlines lines above and one underneath subtitles (##, ### and so ...
0
votes
1answer
313 views

extract word from file using information from a subset of the file (multiple steps)

I have two large files that look like the following: File 1: NW_006502347.1 316684 NW_006527876.1 351 NW_006502151.1 27628 NW_006526579.1 232 NW_006525259.1 132 NW_006501641.1 437014 NW_006525259.1 ...
1
vote
2answers
664 views

pcregrep excluding multiple lines regexp eats one more line than needed

I want to filter out all lines starting with banana and all lines starting with a space after banana lines. I am using pcregrep. Consider the following file fruits.txt: apple banana starts matching ...
1
vote
1answer
116 views

regexp: non-empty line followed by “From ”

I'm in the process of migrating my Mbox format emails to the Maildir format. To this end I use mb2md which works great. Nevertheless I've just come to realize that sometimes in my Mbox folders a ...
0
votes
1answer
196 views

grep command to match the character required [closed]

I am currently using this below command for getting the total snapshot usage of the storage, but this will only show the value in G not in T: # isi_classic snapshot usage | tail -n 1 | egrep -o "[+-]?...
-1
votes
1answer
574 views

grep pattern syntax [closed]

i have a file with names which i make with three files. i want grep 0 if the pattern is absent from any file and 1 if the pattern is present i am using this command cat X.nam |xargs -i grep -c -P '{}$...
0
votes
1answer
81 views

how grep text upto next space?

7/04/27 10:50:17 INFO Master: Driver submitted org.apache.spark.deploy.worker.DriverWrapper 17/04/27 10:50:17 INFO Master: Launching driver driver-20170427105017-0000 on worker worker-20170427103840-...
-1
votes
1answer
348 views

Exclude all hidden directories with grep and pcregrep

I'm trying to exclude all hidden directories from recursive search. I think .*/\..* this should match hidden directories and this indeed works with find, however grep doesn't think so. pcregrep -rnI ...
1
vote
3answers
90 views

How to cat a file with “or” options

I have a file name like /etc/auto.abc on server 1 /etc/auto.def on server 2 /etc/auto.ghi on server 1 I am writing a single script for all servers and in that I want to cat the file. Example: cat /...
1
vote
2answers
134 views

Comment particular lines using regular expression and sed

I have a very big verilog file(~350 MiB). In that, I want to comment particular module names.So i took a sample file and tried my regular expression on it. Sample file(abc) :- module ...
3
votes
3answers
2k views

Print up to (and including) the nth occurence of a pattern in a line

Let's say I have multiple lines similar to below in a file. Turbo is a cat. cats are good. cats are not dog. Coco is a black cat. cats are furry. cats are not dog. now, if want to grep all the ^.*...
-1
votes
1answer
3k views

How do I use grep to search for strings that exist both on single lines and multiple lines?

I am searching large amounts of SQL scripts for data dependencies, but due to variations in the scripts, I have encountered an interesting problem. If I am searching for the word FROM, it only ...
0
votes
2answers
1k views

Is `grep -P` (Perl/Python regex) portable on most linux distributions

I prefer (Perl/Python Compatible Regular Expressions) regular expressions. man grep: ...., but only work if pcre is available in the system Is this supported on the most common linux ...
5
votes
1answer
3k views

How to perform a multiline grep across multiple files?

I'm trying to grab this pattern wherever it occurs in multiple log files (Note:these patterns can vary greatly in size, i.e. the amount of Blahs): Found an txt File Blah Blah 10019874 ...
3
votes
1answer
723 views

pcregrep newline lookbehind assertion bug?

Attempting to use pcregrep to print the first line after a blank line. For example, contents of file first line second line I need second line to be printed. Here are a few tests using the same ...