Saturday, May 5, 2012

What's the fastest way to locate a WORD in a file via the command line?

cat path/to/your/file.txt | grep the_word_you_want_to_find
This technique comes in handy when you're trying to locate a certain configuration directive within a configuration file (as illustrated in the following example):
cat /etc/php5/apache2/php.ini | grep upload_max_filesize
upload_max_filesize = 2M

No comments:

Post a Comment

About Me

My photo
I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.