![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Transfer file from local unix server to remote server | indira | Shell Programming and Scripting | 2 | 05-03-2007 06:35 AM |
| Transfer file from local unix server to remote server | indira | HP-UX | 2 | 05-02-2007 05:15 PM |
| How to check the file status in a remote server? | rajus19 | Shell Programming and Scripting | 3 | 04-28-2006 04:45 AM |
| FTP a file to a remote Server | shivaraj | Shell Programming and Scripting | 2 | 02-26-2006 03:29 AM |
| FTP - Get the file date and time on the remote server | gthokala | Shell Programming and Scripting | 12 | 06-28-2005 08:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Get the most recent file from a remote server
Hi,
This is an FTP related query.I hvae 2 files in a remote server with the timestamp attached to it. FilenameYYYYMMDDHHMMSS.EXT. I need to extract both the fileswith the most recent timestamp using the FTP script I have used : ftp Servername blah blah.... MOST_RECENT_FILE1=`ls -1t ${FTP_OUTPUT_DIR}${FTP_OUTPUT_FILE1}* | head -1 ` get ${MOST_RECENT_FILE1} ${FTP_INPUT_DIR}${FTP_INPUT_FILE1}.EXT The parameter names speak for themselves. I am unable to extract the most recent file using ls and head and i get the message FILE NOT FOUND. Is there an alternative ? Thanks, |
|
||||
|
Thanks for the reply.
I did not understand what you mean by 'massage the listing'. there are numerous files in the remote directory and I cannot get all of them into the local machine and then pick the recent one. I need to pick the recent file in the remote and get only that file. Please let me know if you have any questions. |
|
|||||
|
Quote:
Code:
ls [ remote-directory | -al ] [ local-file ]
Prints an abbreviated listing of the contents of a
directory on the remote machine. If remote-directory
is left unspecified, the current working directory is
used.
The -a option lists all entries, including those that
begin with a dot (.), which are normally not listed.
The -l option lists files in long format, giving mode,
number of links, owner, group, size in bytes, and time
of last modification for each file. If the file is a
special file, the size field instead contains the
major and minor device numbers rather than a size. If
the file is a symbolic link, the filename is printed
spool that listing to the 'local' machine's file. 'massage' the listing on the local machine to determine the 'newest' file. ftp 'get' the "newest" file from the remote machine. |
|
||||
|
Got it.
But it is a pretty crude method. Liste the files on the local machine. sorted and got the most recent file. Again FTP'ed to the remote server and did a 'get' to get the recent file. I wonder if there is a way to do it in one shot. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|