Search code examples
linuxsymlink

sym link parent dirs


ln basic question from a beginner:

I have some legacy code that looks for a series of files at a location

/a/b/c/d/e/f/g/h/i/

for example

/a/b/c/d/e/f/g/h/i/abc.xml

the files are really at a location

/z/w/v/d/e/f/g/h/i/

I tried to link /z/w/v to /a/b/c like

mkdir /a/b/c
ln -s /z/w/v /a/b/c

but when I cd /a/b/c I end up one level higher. Is it possible to ln the parent dirs like this or I just have to link the files?


Solution

  • The problem is that the directory /a/b/c already exists, because of the mkdir. So when you make the link, it thinks you want to make a link in the c, not from c itself. So it's as if you did:

    ln -s /z/w/v /a/b/c/v
    

    Do it like this:

    mkdir /a/b
    ln -s /z/w/v /a/b/c