Reputation: 5273
I mistyped |(bar) as \ (backslash)
locate abcdef \ grep 2
like this. Then bash start to find all files that include '2' in their name.
Why this happen?
Upvotes: 2
Views: 259
Reputation: 59486
The backslash just escaped the space after it from being interpreted by the shell as a delimiter of arguments. So what you now called was the locate
command with three arguments, the first being abcdef
, the second being grep
(with a leading space), and the third being 2
.
locate
in such a case lists all the files which have at least one of the search terms in them.
Upvotes: 3
Reputation: 733
your command will locate the all files in the system which has 2 in its file name. Because \ is a globbing character, which disables the implicit replacement of NAME by *NAME*
.
locate filename \ grep 2
this will neglect the filename and start searching for for file which has 2 in its filename
Upvotes: 0
Reputation: 785376
Your command:
locate abcdef \ grep 2
made rest of text after locate
i.e. \ grep 2
as arguments for locate
command hence it started processing locate
command (grep didn't execute at all).
Upvotes: 5