I have a string containing the file system path to an existing symlink. I want to get the path that this link points to.
Basically I want the same that I'd get through this bit of hackery:
s = "path/to/existing/symlink" `ls -ld #{s}`.scan(/-> (.+)/).flatten.last
but I want to do it without shelling out.
The Symlink option (Symlink Target Operations) only appears in the context menu from ClearCase Explorer after right-clicking on an actual symbolic link. If the symlink target is in another VOB, then that VOB must also be mounted on the local system.
When you right-click a file to open up "Properties" window, it includes an additional tab: "Link Properties", showing the Target of symlinks. You can also edit this Target field to change the symlink's target. And since the field is editable, copy-paste of the target link is easy.
Showing soft link using Find command in Unix When you use the find command with option type and specify the type as small L ( l for the link), it displays all soft links in the specified path.
Use the ls -l command to check whether a given file is a symbolic link, and to find the file or directory that symbolic link point to. The first character “l”, indicates that the file is a symlink. The “->” symbol shows the file the symlink points to.
I think readlink is what you are looking for:
File.readlink("path/to/symlink")
require 'pathname' Pathname.new("symlink").realpath
or readlink as others said
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With