All Questions
80
questions
1
vote
7
answers
313
views
Find all lines between two patterns, EXCLUSIVE of the second pattern?
Consider that I have the file listed below. I need to select all lines from every instance of the regex pattern Word A to before the regex pattern Word D.
Word A
Word B
Word C
Word D
Word E
Word F
...
3
votes
3
answers
207
views
Print a line matching pattern1 unless next line contains pattern2
I want to match lines that have foo unless the next line contains bar. So given a file containing:
1 foo 1
foo 2
baz bar bap
only 1 foo 1 would print. I got this to work using a negative lookahead /...
1
vote
3
answers
384
views
Filter git log of pom.xml using regex with grep/perl
I'd like to filter the content of a log of a pom.xml file using a regex.
I created it on regexr and it works using PCRE; this is my regex:
commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0)
I then ...
3
votes
2
answers
282
views
Find regex occurrances on block device (line length buffer issue)
I'm trying to find all numbers on two block devices that start with a # character, are between 1635700000 and 1653699999, and end either with a null character (\0) or a linux newline (\0xA).
I came up ...
0
votes
1
answer
218
views
Sorting lines based on certain digit pattern
Assume I have a text file with the following lines:
192.168.1.1.55555
192.168.1.1.55555
192.168.1.1.5555
192.168.1.1.555
192.168.1.1.55
192.168.1.1.55
192.168.1.1.5
8.8.8.8.4433
8.8.8.8.443
8.8.8.8....
0
votes
2
answers
451
views
Extract function string before function name with regex
I want a regex that would search for something like:
package_name.some_function_name.foo()
that would be part of a line and would and extract the some_function_namebut it should be able to work ...
4
votes
8
answers
1k
views
Find files with matched whole lines from a file
I have a file with this content:
$ cat compromised_header.txt
some unique string 1
some other unique string 2
another unique string 3
I wanted to find all files that have all the lines of above file ...
0
votes
3
answers
228
views
Range of lines in file
I have a file with a few o lines:
C 1.31729690416596 -0.05166770188922 0.05026556004853
C 2.15676687192808 -0.87605403673920 0.93010807487406
C 1.45516592682388 -0....
0
votes
6
answers
415
views
Split each line by a delim read from another file and store all split word compounds in the result file
I want to split each line from file names by each and every delimiter from file delim and store the unique word compounds into result file compounds. Lines from names that were not split should be ...
1
vote
3
answers
2k
views
Grep string inside double quotes & single quotes
I want to find the string inside double quotes or single quotes in a text file(the text file is multiline),
for example:
I have a
test "foo bar1" test2 "foo\"bar2",
"...
0
votes
2
answers
202
views
How to use grep -f and perl to replace file inline substituting new lines with ";X"
I have the following file:
$$ head on_this_file.txt
Instance,Session,SenderCompID,Type,SrcAddr,SrcPort,DstAddr,DstPort,Protocol,Client,MIC,curr
304,PBAR29,PBAR29,V,146.127.180.96/27,,162.69.138.157,...
1
vote
3
answers
668
views
one shell command to find every n-gram works in text
I have a text stream or a file that contains words separated by whitespace.
Like:
I have a toy. you may not like it.
Every whitespace-separated word may be composed by two or more small words, ...
0
votes
1
answer
2k
views
Is GNU grep's -P option safe to use in production?
The man pages for grep on Ubuntu 18.04 and CentOS 8 have this to say about the -P option for grep:
-P, --perl-regexp
Interpret the pattern as a Perl-compatible regular expression (...
0
votes
3
answers
1k
views
Extract module name and instance name from verilog/System Verilog file
I have a verilog/System Verilog file from which I want to extract only module_name and instance_name.
From following single line:
module_name #(.ANY_PARAMETER(.ANY_PARAMETER),.ANY_PARAMETER_1(....
1
vote
2
answers
112
views
Editing the output of fslint with shell tools awk | grep | sed
The task is to transform this text file, output of the utility fslint, into a bash script with rm command lines for the duplicate file(s) to delete and commented lines for file(s) to keep, according ...