Skip to main content
added 285 characters in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

Using ls from GNU coreutils (default on most Linux systems):

$ ls -v -1

This will list the filenames in one single column (-1), sorted using the natural sort order for numbers within the filename ("version sorting", -v). This assumes that all filenames have the same prefix string up to the actual number (anacovaux_ for example).

For systems without GNU ls:

$ print '%s\n' * | sort -t '_' -k2,2n

This will sort the names on the number after the first _ character in the name. Again, it assumes that the filename prefix is constant (this solution totally ignores the prefix up to the first _).

Using ls from GNU coreutils (default on most Linux systems):

$ ls -v -1

This will list the filenames in one single column (-1), sorted using the natural sort order for numbers within the filename ("version sorting", -v). This assumes that all filenames have the same prefix string up to the actual number (anacovaux_ for example).

Using ls from GNU coreutils (default on most Linux systems):

$ ls -v -1

This will list the filenames in one single column (-1), sorted using the natural sort order for numbers within the filename ("version sorting", -v). This assumes that all filenames have the same prefix string up to the actual number (anacovaux_ for example).

For systems without GNU ls:

$ print '%s\n' * | sort -t '_' -k2,2n

This will sort the names on the number after the first _ character in the name. Again, it assumes that the filename prefix is constant (this solution totally ignores the prefix up to the first _).

Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

Using ls from GNU coreutils (default on most Linux systems):

$ ls -v -1

This will list the filenames in one single column (-1), sorted using the natural sort order for numbers within the filename ("version sorting", -v). This assumes that all filenames have the same prefix string up to the actual number (anacovaux_ for example).