Search code examples
ls

What is the purpose of --file-type in ls command


I'm trying to understand the purpose of the --file-type argument of the UNIX ls command.

I didn't find any example using ls --file-type on the web – neither was I able to make sense of the --file-type argument by issuing ls --file-type myself.

What's the purpose of ls --file-type? Would anyone please give me a helpful example of ls --file-type making the purpose of this argument more clear to me?


Solution

  • Quoting from 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 is just like -F, except that it doesn't append * for executable files:

    $ ln -s /etc/passwd foo
    $ touch bar; chmod +x bar
    $ ls
    foo  bar
    $ ls -F
    foo@  bar*
    $ ls --file-type
    foo@  bar
    ...
    ...