hi as a continue to may previous question ( ls command error via SFTP in Linux shell script ) i have a question: How can i get the name (or enter) of the latest created directory via SFTP connection ?
As i was told here the function ls -tr | tail -1 option won't work here, as parameters as -tr are not recognized in SFTP.
for example the script after SFTP connection:
cd temp_dir
?????????
assuming that the temp_dir containing several directories, i need to enter the last created directory in it (in order to download the files from it). how can i do that ?
Thanks.
sftp使用ssh时,更好的解决方案是ssh
到服务器和:
cd $(ls -t | sed q)
Your previous question contains the essential fact that you use lftp
; therewith using cls
instead of ls
will help.
cls -1t|sed -n 1s/^/cd\\ /p>/tmp/cd
source /tmp/cd
Beware, this uses the file /tmp/cd
and is not suited for concurrent operation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.