I need to use GNU find command in order to locate files of the pattern, described by POSIX BRE below:
"_[[:digit:]]*.txt"
(underscore followed by any number of digits followed by period followed by "txt")
When the target file names are put into single text file, I can successfully select the interested ones using grep with the above mentioned RE. However, find with --regextype posix-basic does not find any matches.
E.g.:
$ touch 1.txt _2.txt _3_r.txt _3.txt 3.txt
$ for i in $(ls); do echo $i >> files.txt; done
$ grep "_[[:digit:]]*.txt" files.txt
_2.txt
_3.txt
$ find . -regextype posix-basic -regex "_[[:digit:]]*.txt"
$
Do grep and find have different syntax for POSIX BREs? How do I then construct an RE to select the file names of interest (_2.txt and _3.txt in the example).
According regex-section from man find
:
This is a match on the whole path, not a search. For example, to match a file named `./fubar3', you can use the regular expression `.*bar.' or `.*b.*3', but not `f.*r3'.