I have a bunch of files in a folder that all end in a different version number, like 1, 2, 3, etc. Some of them have extensions, some of them don't. Is there any way I could use a command like ls, find, or grep that can list all of the files that end in a specific character, like '1', that may or may not end in an extension?
For example, in a directory, I have the following files: ver1.txt
, ver1
, and file.1
. I'd want to do something that would return ver1.txt
and ver1
, but not file.1
, if that helps any. I've tried using something like ls *[1.]*
but that's not doing what I want...
Pure find
:
find . -regex '\.[^.]*1\|.*1\.[^.]*'
This will match ver1
and ver1.txt
and file1.ver1.txt
, but not file1.ver2.txt
. If you want to match that too:
find . -regex '\.[^.]*1\|.*1\..*'
You must run these commands inside searched directory, find somepath ...
whouldn't work, as regex match whole path.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments