Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dickguertin

macrumors newbie
Original poster
Sep 4, 2010
14
0
Mountain View, CA
I'm using Terminal.app in Yosemite, and I've followed a path through several directories. I'm now at

$HOME/Library/d1/d2/d3/d4 (the d's are directory names). ls -l shows me the content of d4, and one of the entries is a symlink that looks like this: ColorSync -> ../../../../ColorSync

If I just do "ls -l ColorSync", I see the long form of display ending with what you see above. Notice there are four (4) backup steps, which would say ColorSync exists in Library. If I try "ls -ldL ColorSync", I get the same response as for just the -l option alone. That's because there is no ColorSync file in Library. But if I removed the 'd' and use "ls -lL ColorSync", I'm told "ColorSync: No such file or directory". If the symlink points to a directory, such as "d1 -> ../../../d1", then "ls -ldL d1" shows the d1 directory. If I leave out the 'd', is shows the contents of the directory. How do I get "ls -ldL something" to show me a directory at symlink location, OR tell me a file is missing at that location?
 
If the final target of the symlink is expected to be a directory, you can force it to be resolved by appending "/." to the symlink's pathname. Since "." always refers to "the referenced directory itself", then it's always safe to use it in any pathname expression involving directories. This only works when the expected final target is a directory. You can't use it to force the resolution of ordinary files.

For example, "/etc" might be a symlink. To force it to resolve to the target directory, use "/etc/." instead.

The "." can also be repeated. For example, "/bin", "/bin/.", and "/bin/./." all refer to the same thing.

I'll also refer you to the commands 'stat' and 'readlink'.
 
Just because there is a symbolic link doesn't mean the target of the symbolic link actually exists. It may not. You can make a symbolic link to whatever path you want. Your command said the ColorSync directory doesn't exist. So clearly that symbolic link points to a directory that doesn't exist.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.