By way of example, I have a directory structure like this:
$ \ls -F
dir/ lnk@
$ \ls -F dir
FILE
$ \ls -l lnk
lrwxrwxrwx 1 user group d Mon hh:mm lnk -> dir
My ls
command is aliased. I am using \ls
to get standard behavior (I think).
The question is
When using the -F
option with ls
, why does appending a slash to the symlink name affect the behavior of ls
?
$ \ls -F lnk
lnk@
\ls -F lnk/
FILE
Without the /
, the symlink itself is listed with an @
indicator/flag/classifier; with the /
, the files in the directory that the symlink references are listed with indicators (FILE
is a regular file).
I'm not sure whether to call the behavior with no options consistent or inconsistent:
$ \ls lnk
FILE
\ls lnk/
FILE
I am not finding an explanation for this in man ls
.
Similar Posts
Using ls command with symbolic links
Show contents of symbolic link
References
Trailing slashes on symbolic links to directories
The IEEE and the Open Group (2004) "Pathname Resolution" subsection 4.11 in The Open Group Base Specifications Issue 6
The IEEE and the Open Group (2018a) "Pathname Resolution" subsection 4.13 in The Open Group Base Specifications Issue 7
The IEEE and the Open Group (2018b) "ls"