I want to list all the files having e
as the nth character in their name in the current directory.
I tried this, but it’s not working:
find -regextype posix-egrep -regex '^./[e]{5}.txt$'
I want to list all the files having e
as the nth character in their name in the current directory.
I tried this, but it’s not working:
find -regextype posix-egrep -regex '^./[e]{5}.txt$'
2
Answers
You may use:
Regex breakdown:
^
: Start./
: Match./
.{4}
: Match any 4 characterse
: Match lettere
.*
: Match any text-maxdepth 1
finds entries in current directory onlyOr using
print
and glob:Here:
????
: Match any 4 characterse
: Matche
*
: Match any textWhy don’t you just use the standard wildcard stuff from
bash
? As in an example where you wante
as the fourth character:That’ll expand to any file (in the widest sense of the word) in the current directory starting with three characters followed by an
e
.