Afaik, curl
cannot sort the FTP directory listing.
But some FTP servers can sort the listing, usually using a proprietary switch to the LIST
FTP command. If your FTP server can do that, you should be able to use -X
/--request
switch to tell curl
what command to use. For example, if your FTP server understands the -t
switch (ProFTPD, vsftpd):
curl -X "LIST -t" -u username:pass ftp://example.com/remote/path/
If your FTP server cannot do that, you will have to sort the listing from curl
output locally. Something like this:
How to use Linux command Sort to sort the text file according to 4th column, numeric order?