开发者

Check for symbolic link

开发者 https://www.devze.com 2023-02-02 06:09 出处:网络
I have a symbolic link a.c in my home directory to another file in the same directory. a.c -> b.c I know how to check a.c 开发者_如何学运维is a symbolic link using the shell script

I have a symbolic link a.c in my home directory to another file in the same directory.

a.c -> b.c

I know how to check a.c 开发者_如何学运维is a symbolic link using the shell script

if [ -L /home/nit/a.c ] ; then
    echo "a.c is a symbolic link"
fi

But my question is how to write a shell script to check whether a.c is a symbolic link specifically to b.c ?

Thanks


Use readlink;

[~]> ln -s foo bar
[~]> readlink bar 
foo


You could also do ls -F filename.txt which returns filename.txt@ if it is a symbolic link.

0

精彩评论

暂无评论...
验证码 换一张
取 消