1

Below is the text in question from the manuaul.

--dereference-command-line-symlink-to-dir

Do not dereference symbolic links, with one exception: if a command line argument specifies a symbolic link that refers to a directory, show information for that directory rather than for the link itself. This is the default behavior when no other dereferencing-related option has been specified (--classify (-F), --directory (-d), (-l), --dereference (-L), or --dereference-command-line (-H)).

Below are some commands I ran on my terminal.

$ touch myfile.txt
$ ln --symbolic myfile.txt symlink_myfile
$ ls --classify symlink_myfile 
symlink_myfile@

If the default behavior is to not dereference symbolic links unless a dereferencing-related option has been specified, then why does ls --classify produce 'symlink_myfile@'?

A dereferencing option, --classify, was specified so my symbolic link should have been dereferenced.

1 Answer 1

0

The man page for ls (and most other GNU programs) is only a very simplified summary. In your case, it says that --dereference-command-line-symlink-to-dir is the default unless a dereferencing-related option such as -F is given, but it does not say what happens about dereferencing when -F is given (so it is not wrong, merely incomplete). The entry about -F is not helpful either:

-F, --classify
        append indicator (one of */=>@|) to entries

More helpful information is available in the full documentation, which can be accessed with info ls or online:

‘-F’
‘--classify’
‘--indicator-style=classify’
     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.  Do not follow symbolic links listed on the command
     line unless the ‘--dereference-command-line’ (‘-H’),
     ‘--dereference’ (‘-L’), or
     ‘--dereference-command-line-symlink-to-dir’ options are specified.

So -F does not dereference by default.

1
  • Thanks very much. This helps.
    – raul
    Oct 29, 2019 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .