1

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 sirectory

Why is that?

3
  • You can do single quotes as well. grep 'home/paul/*'
    – zzxyz
    Commented Dec 9, 2017 at 2:32
  • see also mywiki.wooledge.org/Quotes
    – Sundeep
    Commented Dec 9, 2017 at 3:20
  • @Jesse_b - has the appropriate, well-cited answer; but just to place a term with the concept -> here is the Pathname expansion section from the bash manpage. Commented Dec 9, 2017 at 3:49

1 Answer 1

6

From the bash reference manual:

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’.

So you must remove the special character * from your quoted string in order for it to be treated as a wildcard.

grep "hello" "/home/paul/"*
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .