Reputation: 309
How do I perform directory listing but only display directories?
I tried ls | grep '/' but it got rejected with the error : usage: ls remote-directory local-file
This is because command line in FTP is different than your usual linux command line, but I was wondering if there is something equivalent in FTP command
Thanks in advance
Upvotes: 7
Views: 14938
Reputation: 536
using just ftp itself can be an issue, but if you pipe the output to a shell you'll have less of an issue.
ftp -i myhost.com/yolo/ <<< "ls -1R all_files_list.txt"
we can see each listng in that file contains the file permissions signature like "-rwxrwxrw". a little bit of looking and you'll se that all directories start with 'd'
so
grep '^d' all_files_list.txt > only_directories_list.txt
Upvotes: 0
Reputation: 14051
The FTP protocol does not directly support such a feature. It does, however, allow for a broad interpretation that some servers use to accept things like using ls
-style arguments (e.g. LIST -d
, as mentioned by bdk).
Without such a broad interpretation by the server, you are left with retrieving this information from the listing. Unfortunately the standard doesn't provide a fixed format for this either (although it seems most servers use the ls -l
formatting).
Upvotes: 7