How can I display latest files in sftp prompt

How can I display latest files in sftp prompt?

Like " ls -ltr " in unix shell
kitchas23Asked:
Who is Participating?
 
TintinConnect With a Mentor Commented:
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.
0
 
TintinCommented:
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.
0
 
kitchas23Author Commented:
No Tintin, it does not work.
$ sftp dtessh@twcos
Connecting to twcos...
sftp> ls -lt
Invalid flag -t
sftp>
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
TintinCommented:
Do you know what ssh client and server you have?

Is the -l flag supported in your version?
0
 
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
0
 
TintinCommented:
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"
0
 
kitchas23Author Commented:
sftp> version
SFTP protocol version 3
sftp>
0
 
kitchas23Author Commented:
No I can't. Its restricted only to use scp or sftp.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.