Wednesday, August 17, 2011

How to Find Keywords from Files in Ubuntu

I personally have wasted much time finding keywords within files, when I wanted to debug programming codes in Ubuntu.
Here is how it is done easily.

The function we use is called grep. Most of the Ubuntu distributions come with grep installed.

If you want to find my_function in all the files in folder /home/abc
type:
grep -i -n -r 'my_function' /home/abc

definition:
grep - function to search patterns in files
-i - ignore case
-n - output line number
-r - search recursively

Use
grep --help or man grep for more details.


Thanks for reading this post. Hope it would help!

No comments:

Post a Comment