-->

Recent News

BASH: grep - hide filenames without matching patterns

Hello ,

If you want to get count for pattern matchings in a file then you would use " -c" flag like we all do. It will print matching files with count in the ending and non matching files with count as :0 in the ending. If you are doing this for 100 files your screen will flood with matching and non-matching details.

To get clear picture of only matching, if you can pipe( | ) your result into grep -v ':0$' then you will get results only for matching files.

so full command would be

grep 'your_pattern' file_list* | grep -v ':0$'
Thats it!!

Hope it helps.

Thanks
Raja
Share on Google Plus

About RAJA SEKHAR REDDY GENUPULA

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

Technology

Connect With us

Comments