Tuesday, July 15, 2014

How to see number of lines of files with names containing one but not other pattern

If you want to see number of lines for each of the files in your folder that contain one pattern in their names but not the other one use wc and pipe it with grep.

For example to see count of lines for files that end with .bed and do nt contain 'peaks in their names use:

wc -l *.bed | grep -v "peaks"

If you want to see the same but for the files that do contain 'peaks' use:

wc -l *.bed | grep "peaks"

If you want to see the same but for files that end with '.bed', and contain both 'peaks' and 'normalized' use:

wc -l *.bed | grep "peaks" | grep "normalized"

etc.

No comments:

Post a Comment