Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Retrieve the Latest file in a folder using SFTP Post 303028821 by heye18 on Tuesday 15th of January 2019 03:13:56 PM
Old 01-15-2019
Retrieve the Latest file in a folder using SFTP

HI Guys,

Can anyone help me to retrieve the latest file from below example using SFTP

I have below list of files in a folder

Code:
v403t.lstprgms.sortin1
val027.d099.fwest.oct2711
xcelrptd.d1400sqp.dec1713.t040459.@02del
xcelrptd.d1400sqp.dec1713.t073308.@02del
xcelrptd.d1400sqp.dec1713.t083000.@02del
xcelrptd.d1400sqp.dec1813.t040421.@02del
xcelrptd.d1400sqp.dec1813.t073312.@02del
zions.s2550nai.jan0819
zions.s2550nai.jan0919
zions.s2550nai.jan1019
zions.s2550nai.jan1419
zions.s2550nai.jul3018
zions.s2550nai.jul3118
zions.s2550nai.jun1518
zions.s2550nai.jun2918

I need to get latest file that start with filename zions.s2550nai.* by using SFTP
So from above list I need to get only zions.s2550nai.jan1419 (MONDDYY format)

Any thoughts are highly appreciated

Last edited by Scrutinizer; 01-15-2019 at 04:26 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy the latest file from a folder

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies

2. Shell Programming and Scripting

Copying latest file into a folder

Hello all, this is my first post while i am trying to understand unix. I would basically like to know if i can do this: Lets say i have a folderA and folderB And i save something in folderA Can i make a script that checks folderA latest file, then compares it with the date of latest file in... (16 Replies)
Discussion started by: takissd
16 Replies

3. Shell Programming and Scripting

Latest file through SFTP

Hi, I want to download the latest file published on remote server using SFTP connection. The job will run at every 15 min hence should download only the latest file. The fileName will be like ABC_DDHHMISS.txt (DD- day, HH-hour, MI - Min, SS-Sec). So there will be files with same date for... (23 Replies)
Discussion started by: ssachins
23 Replies

4. Shell Programming and Scripting

SFTP latest file from Windows server to Unix host

Hi All, I am SFTP ing file from Windows server (Sydney) to Unix host in London (both servers are on different timezones). It appears the upstream (Windows server team) does not do a file housekeeping activity and henceforth there are multiple files i.e. each week the script is scheduled to run... (1 Reply)
Discussion started by: vigdmab
1 Replies

5. Shell Programming and Scripting

Need to copy latest file using SFTP

Hi All, In my unix server, I have the following files: h1.txt h2.txt h3.txt and through SFTP i need to copy only the latest file to another unix server. Can you please let me know what command i need to use. Thanks in Advance, (2 Replies)
Discussion started by: HemaV
2 Replies

6. UNIX for Dummies Questions & Answers

Copy the latest (last file) in given folder

#!/bin/bash for i in {1..1536..1} do #find /home/test/Desktop/up111/workplace/Malware/$i/logs for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do #max=a for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do ... (4 Replies)
Discussion started by: upvan111
4 Replies

7. UNIX and Linux Applications

Need to copy the latest file from Unix server to Shared folder

Hi All, One job in unix server will generate .csv files daily. I need to copy the latest of these .csv file from the unix server to the shared drive/folder in windows through unix script. My shared folder will look something like W:\some folder(for example). Could any one of you please help... (3 Replies)
Discussion started by: jaya@123
3 Replies

8. UNIX for Dummies Questions & Answers

Find the latest file on remote sftp

Hi All, I need your help in finding the latest files in remote sftp and get those files to local server and process them. Please let me know I appreciate your valuable inputs. Thanks raj (7 Replies)
Discussion started by: rajeevm
7 Replies

9. Shell Programming and Scripting

How to retrieve the latest files from the directory.?

hi, i have some file in a directory say p1.txt.201305051200.lst p1.txt.201305051300.lst p1.txt.201306051200.lst p1.txt.201306051300.lst p2.txt.201306051200.lst p2.txt.201306051300.lst i am using p* pattern to retrieve these file ls -1 p* the files in red color are the latest... (7 Replies)
Discussion started by: Little
7 Replies

10. Shell Programming and Scripting

Need to automate sftp and always get the latest file

hi guys the script is working but i need to change the file that i want to get to the latest.. i will use this as cron so i can get the latest sftp file evryday. pls help.. set user "big_user" set IP "XX.XX.XX" set dir "/export/home/oracle/REF/INPUT" spawn sftp $user@$IP expect sftp> ... (7 Replies)
Discussion started by: JONATHAN0919
7 Replies
libssh2_sftp_close_handle(3)					  libssh2 manual				      libssh2_sftp_close_handle(3)

NAME
libssh2_sftp_close_handle - close filehandle SYNOPSIS
#include <libssh2.h> #include <libssh2_sftp.h> int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle); int libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle); int libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle); DESCRIPTION
handle - SFTP File Handle as returned by libssh2_sftp_open_ex(3) or libssh2_sftp_opendir(3) (which is a macro). Close an active LIBSSH2_SFTP_HANDLE. Because files and directories share the same underlying storage mechanism these methods may be used interchangably. libssh2_sftp_close(3) and libssh2_sftp_closedir(3) are macros for libssh2_sftp_close_handle(3). RETURN VALUE
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se. ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed. LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket. LIBSSH2_ERROR_SOCKET_TIMEOUT - LIBSSH2_ERROR_SFTP_PROTOCOL - An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. SEE ALSO
libssh2_sftp_open_ex(3) libssh2 0.15 1 Jun 2007 libssh2_sftp_close_handle(3)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy