I search SO for something that might give me this simple answer and it seems to be here and here (among many) but I simply can not get it to work.
I have files like
12_pattern1.yyy_zzz #find
13_pattern1.xxx.pattern2_xx
12_yy_pattern1:xxx
14_pattern1.xxx_pattern2.xxx #find
12_xxx_zzz.yyy.xxx
14_pattern1.xxx.yyy #find
I need to find and remove files that start with 12
or 14
, have _pattern1
immediately hereafter and do NOT end with pattern2
.
I tried something along find . -regex ".*/\(12_\|14_\)pattern1.*[^pattern2$]" -exec rm -f {} \;
What am I missing here ?