A
A
Artur Levchenko2020-11-24 09:29:07
linux
Artur Levchenko, 2020-11-24 09:29:07

How to create a regular search for files with 3 to 5 characters in their names?

I need to write a regular expression to find all files in a directory whose name contains from 3 to 5 any characters, without taking into account the names of the directories in which these files are located.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2020-11-24
@ad_levchenko

This crap will find all jpg files with names from three to five characters.

find . -type f -regextype sed -regex ".*/[A-Za-z0-9]\{3,5\}\.jpg"

5fbcb84f73e84267679101.png

V
Valdemar Smorman, 2020-11-24
@smorman

awk, sed , find, grep etc...

S
Sand, 2020-11-24
@sand3001

You can do this, of course, if you put the length of the extension 4 (point plus extension)

find "path/to/dir/" -type f -printf "%f\n" | grep -E "^.{7,9}$"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question