linux 中 readlink、realpath、find输出软链接文件绝对路径的差异

发布时间 2023-09-15 12:12:05作者: 小鲨鱼2018

 

001、

[root@pc1 test1]# ls      ## 三个测试文件
a.txt  b.txt  testfile
[root@pc1 test1]# ll -h
total 4.0K
lrwxrwxrwx. 1 root root 20 Sep 16 12:03 a.txt -> /home/test1/testfile
lrwxrwxrwx. 1 root root 20 Sep 16 12:03 b.txt -> /home/test1/testfile
-rw-r--r--. 1 root root 21 Sep 16 12:03 testfile
[root@pc1 test1]# readlink -f a.txt     ## readlink输出原始文件
/home/test1/testfile
[root@pc1 test1]# realpath a.txt         ## 输出原始文件
/home/test1/testfile
[root@pc1 test1]# find $PWD -name "a.txt"     ## 输出查找文件
/home/test1/a.txt

。