12 useful examples of Linux grep command

In this article, we are going to provide you with useful examples of Linux grep command including the two variant programs: egrep and fgrep. grep (global regular expression print) is used to search for text strings and regular expressions line by line which match a specified pattern within one or more files. Listed below are some simple and useful examples of how to use the grep command on Linux and search for a string in one/multiple files. Search for lines containing DB_USER in WordPress configuration file (wp-config.php): # grep ‘DB_USER’ wp-config.php define(‘DB_USER’, ‘wpuser’); Search for all PHP files containing str_replace [ ]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s