How to see full symlink path

后端 未结 5 1352
悲&欢浪女
悲&欢浪女 2020-12-22 21:15

When I\'m using ls -la symlinkName or stat symlinkName not all the path is displayed (e.g ../../../one/two/file.txt)

What is

5条回答
  •  眼角桃花
    2020-12-22 21:56

    You can use awk with a system call readlink to get the equivalent of an ls output with full symlink paths. For example:

    ls | awk '{printf("%s ->", $1); system("readlink -f " $1)}'
    

    Will display e.g.

    thin_repair ->/home/user/workspace/boot/usr/bin/pdata_tools
    thin_restore ->/home/user/workspace/boot/usr/bin/pdata_tools
    thin_rmap ->/home/user/workspace/boot/usr/bin/pdata_tools
    thin_trim ->/home/user/workspace/boot/usr/bin/pdata_tools
    touch ->/home/user/workspace/boot/usr/bin/busybox
    true ->/home/user/workspace/boot/usr/bin/busybox
    

提交回复
热议问题