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

Comments

Popular posts from this blog

grep: unknown device method

Uploading files to FTP/SFTP using CURL

How to find outgoing IP in Linux ?