Finding filenames that end in a specific character with or without an extension

user3742846

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...

jimmij

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Finding a Specific Character in SQL Statement

From Dev

Finding ranges of specific character in a string

From Dev

'ls -1' : how to list filenames without extension

From Dev

Get filenames from directory from same extension but without the extension (MATLAB)

From Dev

Get filenames from directory from same extension but without the extension (MATLAB)

From Dev

Finding the last specific character type in a string

From Dev

Finding string between 2 specific character

From Dev

Finding a Specific Character and/or String SQL Server 2008

From Dev

Finding the index of a character to match in a specific regex

From Dev

How to Extract the middle characters from a string without an specific index to start and end it before the space character is read?

From Dev

Search specific extension filenames that contain a particular string in Bash

From Dev

Removing files without a specific extension

From Dev

Get a list of filenames without extension for all files in a directory

From Dev

linux find command for filenames without extension for unknown extensions

From Dev

Finding a specific command without an empty line before it

From Dev

PHP - How to add a specific character at the end of a string?

From Dev

Finding the first occurrence of a given/ specific character inside every word

From Dev

Using ls to find files that end in a character, ignoring extension

From Dev

Remove HTML extension for specific URL without Redirect

From Dev

Find filenames with uppercase extension

From Dev

Remove lines without n number of a specific character?

From Dev

Default DICOM encoding without Specific Character Set

From Dev

Add suffix to all files without specific extension and retain the file extension

From Dev

Add suffix to all files without specific extension and retain the file extension

From Dev

Finding a rogue script changing filenames?

From Dev

Trimming Filenames from the end

From Dev

Bash globbing that matches all files except those with a specific extension, that works on filenames that include dot characters

From Dev

Character encoding problem with filenames - find broken filenames

From Dev

Character encoding problem with filenames - find broken filenames

Related Related

  1. 1

    Finding a Specific Character in SQL Statement

  2. 2

    Finding ranges of specific character in a string

  3. 3

    'ls -1' : how to list filenames without extension

  4. 4

    Get filenames from directory from same extension but without the extension (MATLAB)

  5. 5

    Get filenames from directory from same extension but without the extension (MATLAB)

  6. 6

    Finding the last specific character type in a string

  7. 7

    Finding string between 2 specific character

  8. 8

    Finding a Specific Character and/or String SQL Server 2008

  9. 9

    Finding the index of a character to match in a specific regex

  10. 10

    How to Extract the middle characters from a string without an specific index to start and end it before the space character is read?

  11. 11

    Search specific extension filenames that contain a particular string in Bash

  12. 12

    Removing files without a specific extension

  13. 13

    Get a list of filenames without extension for all files in a directory

  14. 14

    linux find command for filenames without extension for unknown extensions

  15. 15

    Finding a specific command without an empty line before it

  16. 16

    PHP - How to add a specific character at the end of a string?

  17. 17

    Finding the first occurrence of a given/ specific character inside every word

  18. 18

    Using ls to find files that end in a character, ignoring extension

  19. 19

    Remove HTML extension for specific URL without Redirect

  20. 20

    Find filenames with uppercase extension

  21. 21

    Remove lines without n number of a specific character?

  22. 22

    Default DICOM encoding without Specific Character Set

  23. 23

    Add suffix to all files without specific extension and retain the file extension

  24. 24

    Add suffix to all files without specific extension and retain the file extension

  25. 25

    Finding a rogue script changing filenames?

  26. 26

    Trimming Filenames from the end

  27. 27

    Bash globbing that matches all files except those with a specific extension, that works on filenames that include dot characters

  28. 28

    Character encoding problem with filenames - find broken filenames

  29. 29

    Character encoding problem with filenames - find broken filenames

HotTag

Archive