Skip to content

Commit

Permalink
ftp-advanced: Directory listing
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Dec 17, 2016
1 parent fb62654 commit 3f5be48
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ftp-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

## Directory listing

TBD
You can list a remote FTP directory with curl by making sure the URL ends with
a trailing slash. If the URL ends with a slash, curl presumes that is a
directory you want to list. If it actually isn't a directory, you will most
likely instead get an error returned.

curl ftp://ftp.example.com/directory/

With FTP there is no standard syntax for the directory output that is returned
for this sort of command that uses the standard FTP command `LIST`. The
listing is usually humanly readable and perfectly understandable but you will
see that different servers will return the listing in slightly different ways.

One to get just a listing of all the names in a directory and thus to avoid
the special formatting of the regular directory listings, is to tell curl to
`--list-only` (or just `-l`). curl then issues the `NLST` FTP command instead:

curl --list-only ftp://ftp.example.com/directory/

NLST has its own quirks though, as some FTP servers list only actual *files*
in their response to NLST; they do not include directories and symbolic links!

## Uploading

Expand Down

0 comments on commit 3f5be48

Please sign in to comment.