i want to display all links in a directory in the following format:
linkname -> path/of/the/link
How can i do this?
Advertisement
Answer
You can use find to search for symbolic links and use the builtin function printf to make it look like you want:
find . -maxdepth 1 -type l -printf "%f -> %ln"
Explanation: find . searches in the actual directory, -maxdepth 1 only looks this directory, if omitting find runs through all subdirectories, -type l looks only for symbolic links, %f means the filename and %l the target of the link (empty if no link)