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?

  • You can do single quotes as well. grep 'home/paul/*' – zzxyz Dec 9 '17 at 2:32
  • see also mywiki.wooledge.org/Quotes – Sundeep Dec 9 '17 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. – Travis Clarke Dec 9 '17 at 3:49
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/"*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.