All Questions
59
questions
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, ...
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 ...
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 ...
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?
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 ...
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 ...
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?
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 ...
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?
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 ...
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?
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 ...
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 ...
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 $...