openharmony 鸿蒙 kernel-small-debug-shell-file-ls

2022-08-09 浏览 (886)

ls

Command Function

This command is used to display the content of a directory.

Syntax

ls [-ACHLSZacdfhiklmnopqrstux1] [--color[=auto]] [directory...]

NOTE
During the system boot process, ls=toybox ls --color=auto, ll = ls -alF, la=ls -A, and l=ls -CF commands have been enabled using alias so that the initial actions of these commands are the same as those on Linux. For details, see Output. To view help information, run toybox ls --help.

Parameters

Table 1 Command parameter description

ParameterDescriptionValue Range
--helpDisplays parameters supported by the ls command and their usage.N/A
-aDisplays all files, including hidden files.N/A
-bEscapes non-graphical characters.N/A
-cUses ctime as the file timestamp. This parameter must be used together with -l.N/A
-dDisplays only the directory, rather than listing the content of the directory.N/A
-iDisplays the node ID of a file.N/A
-pAdds a slash (/) after the directory.N/A
-qDisplays non-printable characters, such as "?".N/A
-sProvides information about the memory occupied by the directory and its members, in 1024 bytes.N/A
-uUses the last access time of the file as the timestamp. This option is used together with -l.N/A
-ALists all files except implied . and ..N/A
-HFollows symbolic links listed in the command line.N/A
-LFollows symbolic links.N/A
-ZDisplays security context.N/A
pathSpecifies the path of the target directory.
If path is left blank, the content of the current directory is displayed.
If path is an invalid directory, "ls error: No such directory." is displayed.

If path is a valid directory, the content of the specified directory is displayed.
Left blank
A valid directory

Table 2 Output format parameters

ParameterDescription
-1Lists one file per line.
-cLists entries by column.
-gLike -l, but do not list the owner.
-hDisplays the total size of files in the directory, in KiB.
-lDisplays detailed information about files in the directory.
-mFills width with a list of entries separated by a comma.
-nLike -l, but lists numeric user and group IDs.
-oLike -l, but do not list group information.
-xLists entries by line, instead of by column.
-llLists the file time attribute as ns.

Table 3 Parameters for sorting (by the initial letter by default)

ParameterDescription
-fDo not sort.
-rSorts in reverse order.
-tSorts by time, newest first.
-SSorts by file size, largest first.

Table 4 Color printing

ParameterDefault Configuration
--colordevice=yellow symlink=turquoise/red dir=blue socket=purple files: exe=green suid=red suidfile=redback stickydir=greenback=auto means detect if output is a tty.

Usage Guidelines

The file node information of the FAT file system inherits from its parent node. The parent node ID is 0. Therefore, if you run the ls -i command on the Hi3516D V300 development board, the file node IDs displayed are all 0.

Note

The shell does not support ls parameters. mksh supports them. To switch to mksh, run cd bin and ./mksh.

Example

Run the following commands:

  • ls

  • ll

Output

Example 1: ls command output

OHOS:/$ ls
bin  etc  nfs   sdcard   system    usr
dev  lib  proc  storage  userdata  vendor

Example 2: ll command output

OHOS:/$ ll
total 20
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 bin/
drwxr-xr-x 0 0 0    0 1970-01-01 00:00 dev/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 etc/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 lib/
drwxrwxrwx 0 0 0 4096 2021-10-25 02:17 nfs/
dr-xr-xr-x 0 0 0    0 1970-01-01 00:00 proc/
drwxrwxrwx 1 0 0 4096 1979-12-31 00:00 sdcard/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 storage/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 system/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Kernel

harmony 鸿蒙Kernel Coding Specification

harmony 鸿蒙Standard Libraries

harmony 鸿蒙Interrupt Management

harmony 鸿蒙Event

harmony 鸿蒙Mutex

harmony 鸿蒙Queue

harmony 鸿蒙Semaphore

harmony 鸿蒙Doubly Linked List

harmony 鸿蒙Memory Management

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/9f3c345f6fae4d79a95d0bbbfa1d8f5b