LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   'all files' switch for grep? (https://www.linuxquestions.org/questions/linux-newbie-8/all-files-switch-for-grep-814026/)

maf9222 06-14-2010 05:16 AM

'all files' switch for grep?
 
If I type 'grep alias .bashrc' a whole load of stuff comes up. However, if I type 'grep alias *' nothing comes up. Is there some switch for including 'hidden' files - like the -a switch for ls?

jlinkels 06-14-2010 05:53 AM

Not known according to the man page. But
Code:

grep alias .* *
works.

jlinkels

MTK358 06-14-2010 07:30 AM

The wildcards are expanded by the shell, not by grep.

If you have a directory containing these files:

Code:

.hidden
.hidden2
file
another

And you entered this:

Code:

grep alias *
The shell actually expands the '*' and grep sees this:

Code:

grep alias file another
By default '*' doesn't include files starting with a dot. You can explicitly put a dot before the asterisk to get hidden files only. Or both ".* *" to get all files.


All times are GMT -5. The time now is 01:33 AM.