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

All Questions

Tagged with
1 vote
1 answer
2k views

grep: use square brackets to match specific characters

So I am experimenting with the power of grep using this resources The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
jxhyc's user avatar
  • 181
1 vote
1 answer
325 views

grep not working when I enclose the directory in double quotes

When I do something like this: grep "hello" /home/paul/* It works. But when I do something like this: grep "hello" "/home/paul/*" grep display the error: grep: /home/paul/*: No such file or ...
paul's user avatar
  • 495
9 votes
1 answer
1k views

Why does `grep fil*` fail?

I found echo file|grep fil* fails, but echo abcd|grep abc* succeeds. I don't understand it, can someone explain?
tmpbin's user avatar
  • 783
2 votes
1 answer
1k views

bash regex: asterisk gives ambiguous search results with grep

I am using a simple text file to test the * meta-character through grep. The text file is as below: 1 11 111 1111 11111 111111 d da daa daaa b bc bcc bccc Now when I search digit 1 using grep like ...
Sudhish Vln's user avatar
2 votes
3 answers
352 views

grep .* returns results from .bash_history and complains about

I'm new to Linux and so far I've been playing around with some utilities, specifically the grep utility. I decided to create a new file (aptly called 'newfile') with the following content: Lady of ...
Charybdis's user avatar
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