You could use GNU find
:
find * -regextype posix-extended \! -regex '.*[0-9]{8}.*' -prune
If the date is always at the end of the string, and preceded by a .
, you could also use the regex .*\.[0-9]{8}
which would reflect that and reduce the risk of wrongly excluded files.
How it works :
-regextype posix-extended
selects a type of regex suitable for the regex below
\!
negates the meaning of the statement that follows it
-regex '.*[0-9]{8}.*'
matches any file that has eight consecutive digits (ie a date of the form 20150616
)
-prune
prevents find
from listing the sub directories
Other option :
- Add the
-f
option to only list files
EDIT:
On AIX with no support for regular expression in find
, you could use the following (using the standard globing mechanism) :
find * \! -name '*[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*' -prune
Or, if the date is always at the end of the string, and preceded by a .
, the following pattern can be used : *.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]
EDIT 2:
If you want the files to begin with test
, you could use :
find * -prune -type f \! -name 'test*.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
If you don't want to use the filename expansion by the shell and don't have additional directory in that directory, you could also use :
find . -type f \! -name 'test*.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
ls
a requirement or wouldfind
file listing be ok?find . -type f ! -name 'test.log.[0-9][0-9]*'