Type filter
pls
allows the user to only list specific node types in the output.
Arguments
--typ
/-t
can be used to select the node types the user wants to see. The
flag can be specified multiple times to enable multiple file types. Each time it
can take one of these values.
Value | Description |
---|---|
dir | regular folder |
symlink | symbolic link |
fifo | named pipe |
socket | file-based socket |
block_device | block special device file |
char_device | character special device file |
file | regular file |
none | shorthand: no node types |
all | shorthand: all node types |
Mechanism
When parsing the --typ
/-t
flag, values are read from the CLI, in order, and
added to a vector of node types till we encounter a shorthand value. If the
shorthand value is none
, the vector is cleared. If the shorthand value is
all
, the vector is filled with all the node types.
For example, consider the pls
invocation below.
symlink
is added to the list.- All the file types are added to the list, including the already existing
symlink
. - All entries so far are dropped when
none
is encountered. dir
is added to the list.
The final set contains only dir
and so pls
will only list the directories.
Examples
dir/ block_dev@
/dev/disk0 char_dev@ /dev/null fifo| file socket= sym@ ./dir
dir/ block_dev@
/dev/disk0 char_dev@ /dev/null sym@ ./dir
fifo|