Search code examples
linuxsortingls

Sorting file numerically and incrementally


So, I have 1000 files in a folderA.

Let's say:

File_0001, File_0002, File_0003, File_0004, File_0005, . . . , File_1000

Question, how to sort these files every two incremental number and copy these files into another folder (folderB). So that the files in folderB will be like this:

File_0002, File_0004, File_0006,File_0008, File_0010, . . . , File_1000

Any suggestions will be really appreciated.

Thank you


Solution

  • You can also use simple cp command:

    cp File_*[02468] folderB