ljc ljc - 9 months ago 36
Linux Question

link files within directory, with simple command similar to cp

Where my question originated:

  • When running
    cp source/files.all destination/
    , all the files within
    will now also exist in


  • What if I didn't want to duplicate the data from
    , but simply link them (with absolute path). Usually, I would run something like:

    for f in $(ls source/); do ln -s $(pwd)/${f} $(pwd)/destination; done

    Is there a simple command/tool that I can use (e.g.
    ln -a source/files.all destination/
    ) which would create a softlink to all files in a directory, while automatically adding the absolute path as prefix.
    ln -r
    is close to what I need, but the absolute path, not the relative one?

ljc ljc
Answer Source

So I eventually sort of found a simple way to do this:

Simply run ln -s $(pwd -P)/source/* destination/