Grep - Tips to use in linux

Hi all,

As we all know grep is used as a utility to search for a string in files.
Some usage of grep which is useful in day-to-day work.

Search in specific file extensions. Example : - Grep in only .c, .h files

grep -rl --include=\*.{c,h} <search_string> <path to search>
The above command search for the search_string in path to search in only .c and .h files.

How to find the folders larger than 1 GB in the present working directory?

      du -h --max-depth=1 . | grep '[0-9]G\>'

No comments:

Post a Comment