0

For example i need to list files in folder on ftp remote sorted from older to newer

curl ls -ltc -u login:pass ftp://ip:port/path/to/file/

but ls -ltc didnt work. it listing sorted files from A to Z. any ideas guys how to list files using curl and ftp? than you.

supernoob
  • 11
  • 1

1 Answers1

0

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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992