Technical article 105302

How can I page through a long list of files while logged onto an ftp server?

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

I have logged onto an ftp server as an anonymous user.  I am
unable to use "page", "more" or other commands to list files
in a directory, a page or screen at a time.  If I use "ls"
the directory listing is too long.  How can I list those files
and directories so they do not scroll off the screen?

Solution

Below are three methods to view file and directory listings from an ftp server.

1. This first method lists files from a directory on an
ftp site and pipes them to "more".

As an example, use the following (as typed) to list files and pipe the list through "more":

ls -- |more
Note:  Most anonymous ftp sites offer only limited commands and
utilities such as "ls", "pwd" and more.
2. This second method allows use of local programs or scripts
to process a listing of files.  Enclose local commands within a
set of double quotes ("") after listing the directory files.

As an example, use the following set of commands (as typed) to sort all files listed that begin with the characters "read", either uncapitalized or capitalized:

ls -- "|grep -y read |sort"

3. This third method creates a file on the local system that can be processed with local Unix commands such as "grep", "sed", "more", "tail", "sort" or "head", as well as script files.

As an example, use the following commands while logged onto an
ftp server to page through a directory listing:
ftp> lcd /tmp
Local directory now /tmp
ftp> ls -- files
output to local-file: files?_  y
ftp> !page files
A file in the local directory /tmp will be created and named
"files".  Now Unix commands such as grep, sed, more, tail
or head can be used on the file "files".

See also

ftp(TC), ls(C), more(C)

From the Xinuos technical article database, record 105302. Reproduced with permission. The original is at www.sco.com/ta/105302, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.