I have some files in a directory that are named IMG_0001.jpg
… IMG_9999.jpg
. I want to move to another directory the files that lexicographically have a name greater than IMG_9431.jpg
How can I do that?
Linux command line / Move files filtered by lexicographic order
linuxshellsortingunix
Best Answer
You can use
sort
andsed
to get a list of files grater than some-string like this:Here is the magic:
Lines:
NUL
instead of newlines (-print0
)sion
) – note that this only works with GNUsed
, which implements a-z
option to parseNUL
-terminated inputmv
withxargs
And the desired result: