There is a directory containing the following files:
.
├── bla-bla-bla1.tar.7z
├── bla-bla-bla2.tar.7z
├── bla-bla-bla3.tar.7z
└── _bla-bla-bla_foo.tar.7z
In regular expressions, the ^
operator means "any character except for". Thus [^_]
means "any character except for _". E.g.:
"[^_]*.7z"
So, if your intention is to exclude files starting with _
, your full command line would be:
find /backups/ -name "[^_]*.7z" -type f -mtime +180 -delete
If you'd like to exclude any occerance of _
, you can use the and
and not
operators of find
, like:
find . -name "*.7z" -and -not -name "*_*"