Skip to main content

All Questions

Tagged with
-1 votes
5 answers
77 views

multiline grep search into separate files per occurence

I have a file as following: example.txt -1 15 1 0 0 11 -1.0000E+001 1.0000E+001 -1.0000E+001 2 0 0 11 1.0000E+001 1.0000E+001 ...
Honza S.'s user avatar
  • 101
1 vote
2 answers
52 views

replace both filename and filename's content relying solely on pattern found on the name-of-the-file

I'd like to know if it's possible to replace both filename.ext and a matched pattern inside its content regarding a pattern founded on the filename itself using sed (and grep also, maybe?). Let me ...
dAllARA's user avatar
  • 33
3 votes
3 answers
1k views

Find files matching one pattern, but not another, using grep, awk or sed [duplicate]

I need to locate .php and .pl files that do not contain one string (e.g. aaa), but do contain another (e.g. bbb). I'm currently using this command: find /path/ \( -iname '*.php*' -or -name '*.pl*' \) -...
Krackout's user avatar
  • 2,792
4 votes
4 answers
728 views

grep multiple patterns with differing number of matching groups?

I'm trying to tally insertions and deletions from git diffs. I have the following, which when piped one or more strings of the form "4 files changed, 629607 insertions(+), 123 deletions(-)" ...
jawns317's user avatar
  • 143
0 votes
3 answers
757 views

Need to grep the word right next to or below a pattern

I have a file with the following lines in i: .......... FROM ABCD_EXT .......... FROM HEG_EXT1 .......... from xyz_EXT .......... FROM abd_EXT2 ..........where QWT_EXT.SID=POI_EXT....
TexGC's user avatar
  • 31
0 votes
1 answer
232 views

how to detect unbalanced special characters in string

I'm wondering what would be the best way (likely using grep or ack) to return lines containing unbalanced special character sets in a string? For example, if the string were: bqM#+t1U"OyBGhk]ozVG[...
irishwristwatch's user avatar
1 vote
6 answers
1k views

print lines between 1st occurence of 1st pattern to last occurence of 2nd pattern with AWK

I have a datafile, with dates in 2nd column # cat datafile -;20210106;-;-;-; -;20210112;-;-;-; -;20210112;-;-;-; -;20210112;-;-;-; ... -;20210217;-;-;-; -;20210217;-;-;-; -;20210217;-;-;-; -;20210217;-...
Sollosa's user avatar
  • 1,983
1 vote
2 answers
1k views

Why does "grep -w" match words followed by hyphen/minus ("-")?

I need to ask you about using grep command in a Bash script in Debian. I have got for example file with these lines: /fruit-/apple.txt /fruit-/banana.txt /fruit-/samples /vegetables-/carrot.txt /...
SED85's user avatar
  • 45
2 votes
1 answer
1k views

How can grep return a different number of matches?

I need to grep a file (24 lines) into two files (which are kind of big). The original files contains 24 lines that resemble this string: AATGGACGCTTAAC[A|C|T][A|C|G]CGGC[A|T]TCGGAT I do the following:...
gsd's user avatar
  • 401
1 vote
2 answers
308 views

grep partial ip number from the file

I have to sort IP addresses into classes, so I can block entire class in myfirewall. It works fine when I try to do for /24 class, but not so well when do for /16 class. I have a list of IPs in the ...
DenisZ's user avatar
  • 176
-1 votes
2 answers
667 views

Finding files and matching patterns with printed filename in bash

I have the following code that lists matches far a pattern ptrn, with the filename being printed before the listing (which uses the context option -C NUM) find "$fdir" "${isufx[*]}"...
Pietru's user avatar
  • 393
0 votes
2 answers
43 views

Check if the second integer of a line in a file matches

I have a file with the below format of entries. $ cat mw.hosts host23v0242 USER=wsadmin MOUNTPOINT=/web server21v0243 USER=wsadmin ...
Ashar's user avatar
  • 517
3 votes
1 answer
10k views

Grep pattern that has double quotes and variable substitution surrounded by single quotes

So, Let's say I have the following pattern: Thisisatest="1" in a file called file. And I want to match the exact string above but for whatever reason, I choose to loop over some numbers ...
Nordine Lotfi's user avatar
0 votes
3 answers
89 views

Printing all numeric data one by one

I am provided with text file which contains data (alphanumeric, special characters in any order and layout). Now I have to print all numeric data one by one. Example : this is txt *24354 filer3243gdt ...
kuspia's user avatar
  • 324
0 votes
2 answers
146 views

Grep the RHS of the equal too sign [duplicate]

I am grepping into /etc/os-release and then I want to store the output in a variable. I had made a conditional script where I was not needing a variable but now I need one. [[ ${$(grep ID_LIKE /etc/os-...
Supreet Singh's user avatar

15 30 50 per page