Sort directories in 'D' on FTP server


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sort directories in 'D' on FTP server
# 1  
Old 07-07-2015
Sort directories in 'D' on FTP server

Hello,

There are 3 directories on FTP server with format yyyymmddhhmiss.

Can someone please let tell me how do I sort these directories in descending order.

I only have get the files from the latest directory on FTP server.

Code:
ftp>ls -l
20150707011229
20150707061229
20150707131225

ftp> cd 20150707061229
test.zip

Thanks
pavan

Last edited by Don Cragun; 07-21-2015 at 05:58 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 07-21-2015
Seems like maybe you can't in FTP. You might have to retrieve the whole directory and then sort it within your shell script.
# 3  
Old 07-21-2015
Quote:
Originally Posted by pavan_test
Hello,

There are 3 directories on FTP server with format yyyymmddhhmiss.

Can someone please let tell me how do I sort these directories in descending order.

I only have get the files from the latest directory on FTP server.

Code:
ftp>ls -l
20150707011229
20150707061229
20150707131225

ftp> cd 20150707061229
test.zip

Thanks
pavan
Did the ftp command ls -l really just give you a list of files (without, type, mode, owner, group, size, and date information)?

Did you really get test.zip in response to the ftp command cd 20150707061229?

What difference does the order of the list produced by the ftp command ls make to the way your script functions? The ftp command doesn't include any conditionals such that you could extract the first (or last) file produced by ls within ftp and do anything in ftp with those results.

If you are using ftp to get a list of files (in increasing alphanumeric order) and processing the list in the script that called ftp and you want to get the last item in the list instead of the first; can't you just use tail instead of head.
This User Gave Thanks to Don Cragun For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to sort list of directories in descending order in perl?

Hi, I have a problem . I have few directories like inpTDT_1, inpTDT_2, inpTDT_3 and so on inside HOME directory . In one of my perl script (which is in my HOME), the above directories like inpTDT_1, inpTDT_2, inpTDT_3 are sorting out in an order So I wanted to sort all the inpTDT_1, inpTDT_2,... (1 Reply)
Discussion started by: venkatesh
1 Replies

2. Shell Programming and Scripting

Script to sort by size of directories

Hello, I'm trying to find top 5(highest) directories by size. I did something like du -sh * > $file Where I can get all the size with respect to directories, but I need only top 5 directory from the file. How can I sort by size in the file and print top 5 sizes with the directory name??? ... (3 Replies)
Discussion started by: pjeedu2247
3 Replies

3. Red Hat

Implement FTP server on RHEL server without using FTP client

We have RHEL 5.8 in our environment, I had a query whether we can implement an FTP server using vsftpd package and Linux configurations like setsebool without using any external FTP clients like FileZilla etc. I am very confused on this. The FTP functionalities that should be present are download &... (3 Replies)
Discussion started by: RHCE
3 Replies

4. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

5. UNIX for Dummies Questions & Answers

List directories with given string, sort by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, which directories name has given particular string. Example: Directories with name "Build" 2. On the output of 1. list the directories by creation date as sort order. I tried with; find . -type d -name "Build*" ... (3 Replies)
Discussion started by: Siva SQL
3 Replies

6. Shell Programming and Scripting

Sort while you are in FTP!

Hi All, I'm a newbie in Perl.. is it possible to sort the file in ascending order while you are in the SFTP then get the file in the top then process.. and son on and so on.. ex. Server 1 file2 file1 file3 I'm here in Server 2. what i'm going to do is sort the file in Server 1 then get... (8 Replies)
Discussion started by: nikki1200
8 Replies

7. Shell Programming and Scripting

Command to sort directories after a recursive find

find -type d -name "TC_*" | sort That's what I have so far... it finds the appropriate directories and then sorts them. But, when it comes to nested subdirectories, it only sorts relative to the first subdirectory. I want it to sort based on the directory at the end of the path. Does anyone know... (3 Replies)
Discussion started by: crimsondarkn
3 Replies

8. Shell Programming and Scripting

Return all sub directories on ftp server

Hey guys, I'm new to the programming world in general, and I only write in applescript so far. I am trying to find a shell script that will return a list of all the sub directories (or folders) within a directory on my ftp server. The server needs a username and password. I would assume the... (4 Replies)
Discussion started by: thriftinkid
4 Replies

9. UNIX for Dummies Questions & Answers

FTP Directories

Hi Unix Gurus, Been trying to find a thread on this matter but somehow it's not related. I'm trying to ftp a few directories from Unix to the Wintel server but somehow its not working at all :( i've tried to use mput but mput is only working for files but not directory. any suggestion... (1 Reply)
Discussion started by: lweegp
1 Replies

10. UNIX for Dummies Questions & Answers

copying directories from NT server to Unix server (solaris 5.8)

I need to copy around 30 directories (each directory include one or more text file(s)) from NT server to Unix server at one go. For doing this what are the privillages i should have in both NT and Unix server. Please let me know which command i can use in shell prompt. TIA. (4 Replies)
Discussion started by: jhmr7
4 Replies
Login or Register to Ask a Question