Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
3k views

Why is my grep + regex not working?

I recently decided that enough was enough -- I was going to learn to use grep fluently. It's been all of three hours and I'm already stumped by this toy problem. I'm currently syncing a RAID5 array, ...
Louis Thibault's user avatar
8 votes
2 answers
31k views

"grep: Unmatched [" error when using regex

I'm trying to find a pattern similar to this: tail -n 100000 gateway.log | grep -B10 -A10 'Nov 22 11:13:56 Received Packet from [10.50.98.68' Where "11:13:56" could be any time. This is what I came ...
JohnMerlino's user avatar
  • 6,261
4 votes
4 answers
2k views

How can I grep for a string containing regex metacharacters like $ and '?

I want to search all files in the current directory and below for the substring $form['#node']. So, I have tried, initially: grep -R "\$form\[\\\\'" . and grep -R "\$form\[\'" . But it returns no ...
njp's user avatar
  • 327
1 vote
1 answer
1k views

How to grep including single quote in a file

I have this line from file.php: 'user' => '', What would be the appropriate command using grep to query the exact line?
James W.'s user avatar
  • 165
16 votes
4 answers
39k views

How to grep for pipe |

How can I grep for line containing pipe character | or for character >: files content: |this is test where is > this is none now what I need using grep command is grep -iE "<some ...
Özzesh's user avatar
  • 3,729
8 votes
3 answers
33k views

Escaping * with Regular Expressions and Grep

I have a file that has unique lines that start with 2 stars (**). However when I run a grep command for grep \*\* fileName I get all of the lines in the file. This is very unusual, and what I see ...
monksy's user avatar
  • 743
10 votes
2 answers
1k views

What is the difference between "*.pl" and *.pl in grep? Why does quoting change the result?

What is the difference between: grep "string" . -r --include *.pl and grep "string" . -r --include "*.pl" The latter includes files in subdirectoried while the former not. Why?
Jim's user avatar
  • 10.2k
2 votes
3 answers
4k views

Very strange behavior with grep and IFS

I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character... This is the script sample : OLDIFS=$IFS IFS="\\n" i=$(grep -ril $1 *) echo $i IFS=$OLDIFS I ...
Benj's user avatar
  • 123
4 votes
2 answers
56k views

How to tell grep to match special character at beginning of each word [duplicate]

I have certain questions regarding grep. Why does the following command match '<Hello'? $ grep -E "\<H" test Hello World <Hello H<ello What needs to be done to match '<Hello' only?
user3539's user avatar
  • 4,408
5 votes
2 answers
6k views

Use of quotes in GNU grep regular expressions

I could see that certain patterns in the GNU Grep can be enclosed within brackets and certain others need not be. For example, matching the beginning of a word works only if it is enclosed within ...
user3539's user avatar
  • 4,408
4 votes
2 answers
3k views

how to grep for c:\

I'm using cygwin's grep to find all instances of hardcoded paths on c drive. doing: grep -r "c:\\" . gives grep: trailing backslash Does anybody know how I can do this?
noobler's user avatar
  • 199
1 vote
2 answers
3k views

Weird zsh grep -P behaviour

I connect to server with PuTTY from Windows. I have a long yet not touched (I suppose) by hands of local admin config: $ cat /opt/jira/.subversion/config ... ### must be enabled, which is ...
Nakilon's user avatar
  • 144
807 votes
13 answers
1.8m views

How do I grep for multiple patterns with pattern having a pipe character?

I want to find all lines in several files that match one of two patterns. I tried to find the patterns I'm looking for by typing grep (foo|bar) *.txt but the shell interprets the | as a pipe and ...
Dan's user avatar
  • 9,552
57 votes
2 answers
114k views

grep and escaping a dollar sign

I want to know which files have the string $Id$. grep \$Id\$ my_dir/mylist_of_files returns 0 occurrences. I discovered that I have to use grep \$Id$ my_dir/mylist_of_files Then I see that the $...
Luc M's user avatar
  • 4,185

15 30 50 per page
1 2 3
4