When I\'m using ls -la symlinkName
or stat symlinkName
not all the path is displayed
(e.g ../../../one/two/file.txt
)
What is
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
realpath <path to the symlink file>
should do the trick.
realpath
isn't available on all linux flavors, but readlink
should be.
readlink -f symlinkName
The above should do the trick.
Alternatively, if you don't have either of the above installed, you can do the following if you have python 2.6 (or later) installed
python -c 'import os.path; print(os.path.realpath("symlinkName"))'
unix flavors -> ll symLinkName
OSX -> readlink symLinkName
Difference is 1st way would display the sym link path in a blinking way and 2nd way would just echo it out on the console.
Another way to see information is stat
command that will show more information. Command stat ~/.ssh
on my machine display
File: ‘/home/sumon/.ssh’ -> ‘/home/sumon/ssh-keys/.ssh.personal’
Size: 34 Blocks: 0 IO Block: 4096 symbolic link
Device: 801h/2049d Inode: 25297409 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ sumon) Gid: ( 1000/ sumon)
Access: 2017-09-26 16:41:18.985423932 +0600
Modify: 2017-09-25 15:48:07.880104043 +0600
Change: 2017-09-25 15:48:07.880104043 +0600
Birth: -
Hope this may help someone.