< Home

dir/ls (FTP client view)

Function

The dir and ls commands display all files or specified files that are stored on the FTP server, and save them to a local disk.

Format

dir [ remote-filename [ local-filename ] ]

ls [ remote-filename [ local-filename ] ]

Parameters

Parameter Description Value
remote-filename Specifies the name and directory of a file stored on the FTP server. The value is a string of 1 to 64 case-insensitive characters without spaces.
local-filename Specifies the name of the local file that saves the FTP server file information. The value is a string of 1 to 64 case-insensitive characters without spaces.

Views

FTP client view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

The following describes differences between the dir and ls commands.

  • When you run the dir command, detailed file information is displayed, including the file size, date when the file was created, whether the file is a directory, and whether the file can be modified. When you run the ls command, only the file name is displayed.
  • The dir command is used to save detailed file information, while the ls command is used to save only the file name even if the file is specified and saved in a local directory.

Precautions

The wildcard (*) character can be used in commands dir and ls.

Example

# Display the name or detailed information about a file that is saved in the test directory.

<HUAWEI> ftp 10.137.217.201
Trying 10.137.217.201 ...
Press CTRL+K to abort
Connected to 10.137.217.201.
220 FTP service ready.
User(10.137.217.201:(none)):huawei
331 Password required for huawei.
Enter password:
230 User logged in. 
[ftp] cd test 
250 CWD command successfully.

[ftp] dir
200 Port command okay.
150 Opening ASCII mode data connection for *.
drwxrwxrwx   1 noone    nogroup         0 Mar 24 10:48 .
drwxrwxrwx   1 noone    nogroup         0 Mar 26 15:52 ..
drwxrwxrwx   1 noone    nogroup         0 Mar 23 16:04 yourtest
-rwxrwxrwx   1 noone    nogroup      5736 Mar 24 10:38 backup.txt
-rwxrwxrwx   1 noone    nogroup      5736 Mar 24 10:38 backup1.txt 
226 Transfer complete.
[ftp] ls
200 Port command okay.
150 Opening ASCII mode data connection for *.
.
..
yourtest
backup.txt
backup1.txt
226 Transfer complete.

# Display the detailed information for the file temp.c, and save the displayed information in file temp1.

[ftp] dir temp.c temp1
200 Port command okay.
150 Opening ASCII mode data connection for temp.c.

226 Transfer complete.

[ftp] quit

221 Server closing.
<HUAWEI> more temp1
-rwxrwxrwx  1  noone   nogroup  3929  Apr 27 18:13  temp.c

# Display the name of file test.bat, and save the displayed information in file test.

<HUAWEI> ftp 10.137.217.201
Trying 10.137.217.201 ...
Press CTRL+K to abort
Connected to 10.137.217.201.
220 FTP service ready.
User(10.137.217.201:(none)):huawei
331 Password required for huawei.
Enter password:
230 User logged in. 
[ftp] ls test.bat test
200 Port command okay.
150 Opening ASCII mode data connection for test.bat.

226 Transfer complete.

[ftp] quit

221 Server closing.
<HUAWEI> more test
test.bat
Table 1 Description of the dir/Is command output

Item

Description

d

Indicates a directory. If this parameter is not present, the command output indicates a file.

r

Indicates that the file or directory can be read.

w

Indicates that the file or directory can be modified.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >