linux - Find filenames with number in name lower than 1950 -
i have following problem: have list of files this
file256name.txt file307list.cvs file2014text.xls
i use command "find" find files number in name lower 1950 previous list have these files listed
file256name.txt file307list.cvs
i tried command
find . -type f \( -iname '*[1-9][0-9][0-9]*' \)
but display files containing number in name >1950
as additional indication files can have different filenames , extensions , position of number unpredictable...i'm looking simple command use find (for me mandatory use find) including formula select files contains numbers lower 1950
also consider limitation of linux version busybox v1.16.1
thanks help
you'll need use regex differenciate decade in respect century:
.*(19[5-9][0-9]|[2-9][0-9]{3}).*
(this find 4-digit numbers greater or equal 1950).
using regex may use negate option of find
files no number >= 1950. eliminate files without number, use second criteria.
i've not tested find, regex use allows 1000 < 1950.
edit:
the full command:
find . -regextype posix-egrep -regex '.*[0-9].*' \! -regex '.*(19[5-9][0-9]|[2-9][0-9]{3}).*'
with busybox's find more escaping necessary:
find . -regex '.*[0-9].*' \! -regex '.*\(19[5-9][0-9]\|[2-9][0-9]\{3\}\).*'
Comments
Post a Comment