ls 命令中 --file-type 的用途是什么
What is the purpose of --file-type in ls command
我正在尝试了解 UNIX ls
命令的 --file-type
参数的用途。
我没有在网络上找到任何使用 ls --file-type
的示例 – 我自己也无法通过发出 ls --file-type
来理解 --file-type
参数。
ls --file-type
的目的是什么?谁能给我一个有用的例子 ls --file-type
让我更清楚这个论点的目的?
--file-type
选项类似于 -F
选项。
-F, --classify
append indicator (one of */=>@|) to entries
--file-type
likewise, except do not append `*'
引用自info ls
:
-F
Append a character to each file name indicating the file type.
Also, for regular files that are executable, append *
. The file
type indicators are /
for directories, @
for symbolic links,
|
for FIFOs, =
for sockets, >
for doors, and nothing for
regular files.
--file-type
就像 -F
一样,只是它不为可执行文件附加 *
:
$ ln -s /etc/passwd foo
$ touch bar; chmod +x bar
$ ls
foo bar
$ ls -F
foo@ bar*
$ ls --file-type
foo@ bar
...
...
这里有一个例子ls --file-tye /
bin@ boot/ dev/ etc/ home/ lib@ lib64@ lost+found/ media/ mnt/ opt/ proc/ root/ run/ sbin@ srv/ sys/ tmp/ usr/ var/
与 ls -l /
的输出相比
lrwxrwxrwx 1 root root 7 Jan 19 02:32 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Jan 1 1970 boot
drwxr-xr-x 24 root root 4220 Mar 26 19:56 dev
drwxr-xr-x 88 root root 4096 Mar 26 21:15 etc
drwxr-xr-x 4 root root 4096 Apr 5 2020 home
lrwxrwxrwx 1 root root 7 Jan 19 02:32 lib -> usr/lib
lrwxrwxrwx 1 root root 7 Jan 19 02:32 lib64 -> usr/lib
drwx------ 2 root root 16384 Apr 5 2020 lost+found
drwxr-xr-x 2 root root 4096 Dec 11 20:19 media
drwxr-xr-x 7 root root 4096 Sep 8 2020 mnt
drwxr-xr-x 9 root root 4096 Feb 9 13:58 opt
dr-xr-xr-x 335 root root 0 Mar 26 19:56 proc
drwxr-x--- 9 root root 4096 Feb 11 13:18 root
drwxr-xr-x 28 root root 700 Mar 26 21:15 run
lrwxrwxrwx 1 root root 7 Jan 19 02:32 sbin -> usr/bin
drwxr-xr-x 4 root root 4096 Apr 5 2020 srv
dr-xr-xr-x 13 root root 0 Mar 26 19:56 sys
drwxrwxrwt 12 root root 320 Mar 26 22:11 tmp
drwxr-xr-x 9 root root 4096 Mar 25 11:06 usr
drwxr-xr-x 12 root root 4096 Mar 25 11:07 var
如您所见,符号“@
”表示符号链接 (l
)。目录 (d
) 和常规文件 (f
) 未被 --file-type
参数标记。
在我的主目录中发布 ls --file-type
与 ls ~
相同,因为它只包含目录和常规文件,因此前者的输出不包含任何指示器。
另请参阅 PesaThe 的答案以获取指标符号的完整列表。
我正在尝试了解 UNIX ls
命令的 --file-type
参数的用途。
我没有在网络上找到任何使用 ls --file-type
的示例 – 我自己也无法通过发出 ls --file-type
来理解 --file-type
参数。
ls --file-type
的目的是什么?谁能给我一个有用的例子 ls --file-type
让我更清楚这个论点的目的?
--file-type
选项类似于 -F
选项。
-F, --classify
append indicator (one of */=>@|) to entries
--file-type
likewise, except do not append `*'
引用自info ls
:
-F
Append a character to each file name indicating the file type. Also, for regular files that are executable, append
*
. The file type indicators are/
for directories,@
for symbolic links,|
for FIFOs,=
for sockets,>
for doors, and nothing for regular files.
--file-type
就像 -F
一样,只是它不为可执行文件附加 *
:
$ ln -s /etc/passwd foo
$ touch bar; chmod +x bar
$ ls
foo bar
$ ls -F
foo@ bar*
$ ls --file-type
foo@ bar
...
...
这里有一个例子ls --file-tye /
bin@ boot/ dev/ etc/ home/ lib@ lib64@ lost+found/ media/ mnt/ opt/ proc/ root/ run/ sbin@ srv/ sys/ tmp/ usr/ var/
与 ls -l /
lrwxrwxrwx 1 root root 7 Jan 19 02:32 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Jan 1 1970 boot
drwxr-xr-x 24 root root 4220 Mar 26 19:56 dev
drwxr-xr-x 88 root root 4096 Mar 26 21:15 etc
drwxr-xr-x 4 root root 4096 Apr 5 2020 home
lrwxrwxrwx 1 root root 7 Jan 19 02:32 lib -> usr/lib
lrwxrwxrwx 1 root root 7 Jan 19 02:32 lib64 -> usr/lib
drwx------ 2 root root 16384 Apr 5 2020 lost+found
drwxr-xr-x 2 root root 4096 Dec 11 20:19 media
drwxr-xr-x 7 root root 4096 Sep 8 2020 mnt
drwxr-xr-x 9 root root 4096 Feb 9 13:58 opt
dr-xr-xr-x 335 root root 0 Mar 26 19:56 proc
drwxr-x--- 9 root root 4096 Feb 11 13:18 root
drwxr-xr-x 28 root root 700 Mar 26 21:15 run
lrwxrwxrwx 1 root root 7 Jan 19 02:32 sbin -> usr/bin
drwxr-xr-x 4 root root 4096 Apr 5 2020 srv
dr-xr-xr-x 13 root root 0 Mar 26 19:56 sys
drwxrwxrwt 12 root root 320 Mar 26 22:11 tmp
drwxr-xr-x 9 root root 4096 Mar 25 11:06 usr
drwxr-xr-x 12 root root 4096 Mar 25 11:07 var
如您所见,符号“@
”表示符号链接 (l
)。目录 (d
) 和常规文件 (f
) 未被 --file-type
参数标记。
在我的主目录中发布 ls --file-type
与 ls ~
相同,因为它只包含目录和常规文件,因此前者的输出不包含任何指示器。
另请参阅 PesaThe 的答案以获取指标符号的完整列表。