Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is the content of my typescript file,

/mac>ln -s non_exist ~/link
/mac>vi ~/link
Hi!
I am a link.
/mac>cat ~/link
Hi!
I am a link.
/mac>cat non_exist
cat: non_exist: No such file or directory
/mac>exit

Can anyone tell me what actually happened here?

This did not create a file but the following did:

/mac>ln -s non_exist link
/mac>vi link
Hi!
I am a link.
/mac>cat link
Hi!
I am a link.
/mac>cat non_exist
Hi!
I am a link.
/mac>exit
share|improve this question
    
cat ~/non_exist The link refers to a relative path, and the relative path of non_exist from ~/link is ~/non_exist –  William Pursell Jun 5 '13 at 13:30
add comment

migrated from stackoverflow.com Jun 6 '13 at 0:03

This question came from our site for professional and enthusiast programmers.

1 Answer

Symbolic links are relative paths. If ~/link is a symbolic link to non_exist, then the full path of the target of the link is $HOME/non_exist. When you open ~/link with vi, it creates the file named non_exist in your $HOME directory rather than your current directory.

share|improve this answer
add comment

Your Answer

 
discard

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