
- grep (globally search a regular expression and print)
- very old utility, you will be hard pressed to find a linux distro that doesn’t have grep. There can be variations like egrep and fgrep but you can pretty much guaranteed to have grep.
- where
findandlocatewill find file names across a hard drive ,grephas the ability to search not only across a hard drive but inside of files. -
man grep- pulls up the manual page for grep
- grep can do both egrep and fgrep
- a lot of distros have started doing aliases of egrep and fgrep
egrep- searches for an extended regular expression
- eg
egrep N*will search for anything starting with N
- eg
- searches for an extended regular expression
fgrep- searches for a regular fixed string
- eg
fgrep NNNNNwill search for 5 capital N’s no more no less - on most systems
fgrepis aliased togrepbecoming the default,-Einvokesegrep
- eg
- searches for a regular fixed string
aliaswill show you a list of alias’s, this way you can tell howgrepwill behave on your systemtype egrepwill show you an aliaswhich egrepwill show you an alias and where the binary is located- some systems wont have a binary for egrep opting insted to alias
grep -E, this can also be seen withfgrep
- some systems wont have a binary for egrep opting insted to alias
- grep can be pointed at a single file or a whole directory
grep -r [search term]will recursively search the current working directory- its a good idea to get in the habit of specifying where you want to search and not rely on defaults or assumptions
.current working directory..one level above current working directory~users home directory/root level directory
- its a good idea to get in the habit of specifying where you want to search and not rely on defaults or assumptions
Back to the Central Hub