Reputation: 623
I'm trying to figure out why my grep command does not work, which should pick those file names within a folder, that have more than 2 _
in their name:
test_file_1.tsv
test_file_2.tsv
test_fi_le_3.tsv
I'm running in that folder
find . -mindepth 1 -maxdepth 1 -type f | grep -E "_{3,}"
but it returns nothing instead of
test_fi_le_3.tsv
?
Upvotes: 1
Views: 190
Reputation: 785068
Problem is that "_{3,}"
matches 3 or more consecutive underscores.
However, you don't even need a grep
here and use glob pattern in -name
option of find
as this one:
find . -mindepth 1 -maxdepth 1 -type f -name '*_*_*'
./test_file_1.tsv
./test_file_2.tsv
./test_fi_le_3.tsv
Upvotes: 3