如何检查软 link 的最终目标文件是否实际存在?

How to check if the final destination file of a soft link actually exists or not?

1) 如何检查软件 link 的最终目标文件是否确实存在?

2) ls –ltr 显示权限、用户、组、大小、日期时间、名称等。如果您只想查看名称列(没有别的,没有 grepawk 命令)

1) How to check if the final destination file of a soft link actually exists or not ?

要通过简单的 linux 命令实现此目的,您可以使用 stat -L,如果目标文件不存在,这将引发错误。 此外,如果目标文件存在,此命令将 return 0 如果不存在,则 >0 。所以你可以在使用后使用echo $?,检查它是否不为0。

2) ls –ltr shows permission, user, group, size, date time, name etc. what command would you use if you want to see only the name column (nothing else, without grep or awk command)

您只需键入 ls -1 即可单独获取文件名。