Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

In terminal, I have made a symbol link like following:

ln -s ../../../../ jni/prod

It symbol links prod directory (which is 4 levels up from current location) to jni/prod .

I'd like to emphasize that it symbol links a directory NOT a file.

Now, I want to remove this symlink, how to do it?

share|improve this question
1  
What did you try already? –  patrix Nov 6 '13 at 15:09
    
And more importantly, if you don't describe what you "don't get" then people have to guess. Hopefully my guess as to what you don't get about symlinks was correct. –  bmike Nov 6 '13 at 15:21
add comment

2 Answers

up vote 2 down vote accepted

If you find yourself confused about where a file really exists, cd to the directory you expect and use rm -i and refrain from adding any path - delete the file in the current directory. Also, in unix, everything is a file - including a directory. You do have saving grace that trying to delete a file that looks like a directory will pause unless you are recursively deleting files.

Worst case, you could use ls -lai to inspect the inode numbers to be sure a file is really symlinked and not hard linked.

If that doesn't help, make a temp directory and play with links:

touch foo
ln foo bar       # hard link
ln -s foo baz    # sym link
ls -lai
rm foo
ls -lai

At this point, you have the hard link file bar left and a sym link to the missing "foo" file. Since in your case, the link is in a different directory than the target, you shouldn't have too much problem deleting the item you wish.

share|improve this answer
add comment

A symbolic link is a file even if the link is to a directory. So if you simply did an rm that will get rid of the link:

rm jni/prod
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.