
- #Grep command linux recursive how to
- #Grep command linux recursive install
- #Grep command linux recursive code
Just do it and make it part of your default install. Solaris sysadmins often insist on being different from Linux world but there's really no need to.
#Grep command linux recursive install
Personally I would make the above (potentially less the dev tools) part of my company's default install for new servers / zones. R stands for recursive and it also include symlinks. grep -inRsH 'Text to be searched' /path/to/dir (it can be '.') i stands for ignore case distinctions. Pkg://solaris/developer/build/automake-110 This grep command will give you a precise result when you are searching for specific text on Linux. The list of packages that you should consider always to have available for any zone are these:Īnd if you use the host for development/build purpose you might want to add: IFS, the packaging system on Solaris 11, makes your life a lot easier so you really should be moving to Solaris 11 (lots of other reasons as well). The GNU tools are typically installed by default but do not all of them get propagated into local zones. If you are on Solaris 11 life is a lot simpler. Make it part of your JumpStart (or whatever you use) for new servers in your organisation ! Personally I would make it a habbit always to install the contents of this disk or at least the most important GNU parts. This used to be distributed by Sun but it now lives here. If you are on Solaris 10 you should get the Solaris 10 Companion Disk. If you simply want your Solaris to have the typical GNU tools available then do as follows:
#Grep command linux recursive code
I wouldn't go about downloading source code from various places on the Internet and then building yourself. Personally I do not miss the "-r" flag because you can do the same with a combination of find and grep but this reminds that having the GNU tools available on your Solaris box is what I would consider best practice. Recurse in directories skip file matching PATTERN.Īs you’ve seen, the grep -r command makes it easy to recursively search directories for all files that match the search pattern you specify, and the syntax is much shorter than the equivalent find/grep command.įor more information on the find command, see my Linux find command examples, and for more information on the grep command, see my Linux grep command examples.Yes, you will need the GNU grep. Recurse in directories only searching file matching PATTERN. Read all files under each directory, recursively this is Here’s the section of the Linux grep man page that discusses the -r flag:
#Grep command linux recursive how to
Since I tend to mark comments in my code with my initials ("aja") or my name ("alvin"), this recursive egrep command shows how to search for those two patterns, again in a case-insensitive manner:


You can also perform recursive searches with the egrep command, which lets you search for multiple patterns at one time. In this example, the search is made case-insensitive by adding the -i argument to the grep command. This next example shows how to recursively search two unrelated directories for the case-insensitive string "alvin":

Your recursive grep searches don’t have to be limited to just the current directory. If you haven’t used commands like these before, to demonstrate the results of this search, in a PHP project directory I’m working in right now, this command returns a list of files like this: As you’ll see below, you can also add -i for case-insensitive searches.The -l option (lowercase letter L) says “list only filenames”.The -r option says “do a recursive search”.However, I was just reminded that a much easier way to perform the same recursive search is with the -r flag of the grep command:Īs you can see, this is a much shorter command, and it performs the same recursive search as the longer command, specifically: Just run this: grep -v /etc/apache2/nf grep. This command can be read as, “Search all files in all subdirectories of the current directory for the string ‘alvin’, and print the filenames that contain this pattern.” It’s an extremely powerful approach for recursively searching files in all subdirectories that match the pattern I specify. Solution 1: Combine 'find' and 'grep'įor years I always used variations of the following Linux find and grep commands to recursively search subdirectories for files that match a grep pattern:įind. Two solutions are shown next, followed by some additional details which may be useful. Unix/Linux grep FAQ: How can I perform a recursive search with the grep command in Linux?
