I've got files like this:
cap_20151023T122915_791033959.png
cap_20151023T122918_946392456.png
cap_20151023T122920_227637228.png
cap_20151023T122920_875467456.png
and I would like to use the find
command to delete those greater than, for example, cap_20151023T122919*
, which would result in the deletion of cap_20151023T122920_227637228.png
and cap_20151023T122920_875467456.png
.
Is there any way to do this, preferably with a single find
command?
Best Answer
With
zsh
and<[x]-[y]>
glob operator (matches numbers in the rangex
toy
, inclusive; either of the numbers may be omitted to make the range open-ended) e.g.:or, if you want to select only the file names in the
122920-999999
range:so with file names like:
the first one prints:
while the second one prints:
If you're happy with the result replace
print -rl
withrm -f