Link to home
Start Free TrialLog in
Avatar of kitchas23
kitchas23

asked on

How can I display latest files in sftp prompt

How can I display latest files in sftp prompt?

Like " ls -ltr " in unix shell
Avatar of Tintin
Tintin

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.
Avatar of kitchas23

ASKER

No Tintin, it does not work.
$ sftp dtessh@twcos
Connecting to twcos...
sftp> ls -lt
Invalid flag -t
sftp>
Do you know what ssh client and server you have?

Is the -l flag supported in your version?
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"
sftp> version
SFTP protocol version 3
sftp>
No I can't. Its restricted only to use scp or sftp.
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial