In Linux how do I use find and regular expressions or a similar way without writing a script to search for files with multiple “dots” but IGNORE extension.
For e.g search through the following files will only return the second file. In this example “.ext” is the extension.
testing1234hellothisisafile.ext
testing.1234.hello.this.is.a.file.ext
The solution should work with one or more dots in the file name (ignoring the extension dot). This should also work for any files i.e. with any file extension
Thanks in advance
So if I understand correctly, you want to get the filenames with at least two additional dots in the name. This would do:
The key dot detecting part is
\.+(at least one dot), coupled with the separating anything (but a dot, but the previous part covers it already; a safety measure against greedy matching)[^.]*. Together they make the core part of the regex – we don’t care what is before or after, just that somewhere there are three dots. Three since also the one from the current dir matters — if you’ll be searching from elsewhere, remove one\.+[^.]*group:In this case the result is the same, since the name contains a lot of dots, but the second regex is the correct one.