I'm trying to search for all files given a certain string / regex value. So if I were to say search for all files that have "hello" in the name, how would I go about doing this? Ever more complex, how would I go about finding a file whose name begins with any two letters followed by a dash and then a number?
I've tried the find command and that has helped in the situation of hello. I would just type find <dir> *hello*
but this doesn't work with the regex values.
If I type find -E <dir> -regex '^[a-z]{2}-[1-9]'
nothing happens. Even if I type find -E <dir> -regex '*[0-9]*'
, nothing happens.
Could someone help me with this? Thanks in advance
-regex
you'l have to operateregular expression
butpattern matching
. So-regex '.*[0-9].*'
. Additionally note that-regex
mean-wholepath
so.*/[a-z][a-z]-[1-9].*
would work. – Costas Aug 17 '16 at 08:42