How can I display latest files in sftp prompt

How can I display latest files in sftp prompt?

Like " ls -ltr " in unix shell
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you can classify this as a SAQ (Self Answered Question)

At the sftp prompt, you can do

ls -lt

to list the files sorted by modification time.
kitchas23Author Commented:
No Tintin, it does not work.
$ sftp dtessh@twcos
Connecting to twcos...
sftp> ls -lt
Invalid flag -t
Do you know what ssh client and server you have?

Is the -l flag supported in your version?
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

kitchas23Author Commented:
ls -l is supported in my version
sftp> ls -l *BXERPT*
-rw-------    0 7533     200          4633 Nov 10 15:59 CMVN.11052008.155901.ARD.Failed
-rw-------    0 7533     200          4888 Nov 11 14:04 CMVN.11061986.095909.ARD.Failed
-rw-------    0 7533     200          5914 Nov 13 15:49 CMVN.11071986.115159.ARD.Failed
OK, I'm guessing you either have an older ssh client or server.

I'm assuming you want to script this?  If so, I find sftp is not the best tool for scripting.  It's much better suited to interactive use.

Do you have standard ssh/scp access?  If so, then you could do

ssh dtessh@twcos "ls -lt"
kitchas23Author Commented:
sftp> version
SFTP protocol version 3
kitchas23Author Commented:
No I can't. Its restricted only to use scp or sftp.
If that's the case, then unfortunately, you'll have to issue the 'ls -l' in sftp, and then parse the output to get it into date order.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
File Sharing Software

From novice to tech pro — start learning today.