On Thu, May 14, 2026 at 10:51:53 +0200, Nicolas George wrote:
> if [ -f "$HOME/.profile" ] ; then
>   . "$HOME/.profile"
> fi
> 
> A -f instead of -e would exclude symlinks.

-f will follow the symlink and report on whether the target is a
regular file.

hobbit:~$ ln -s .profile symlink
hobbit:~$ ls -l .profile symlink
-rw-r--r-- 1 greg greg 1419 Mar 16  2023 .profile
lrwxrwxrwx 1 greg greg    8 May 14 07:27 symlink -> .profile
hobbit:~$ [ -f symlink ] && echo true
true

As bash's "help test" says:

    All file operators except -h and -L are acting on the target of a symbolic
    link, not on the symlink itself, if FILE is a symbolic link.

Reply via email to