Table of Contents


lndir - create a shadow directory of symbolic links to another directory tree


lndir [ options ] fromdir [ todir ]


The lndir program makes a shadow copy todir of a directory tree fromdir, except that the shadow is not populated with real files but instead with symbolic links pointing at the real files in the fromdir directory tree. This is usually useful for maintaining source code for different machine architectures. You create a shadow directory containing links to the real source, which you will have usually mounted from a remote machine. You can build in the shadow tree, and the object files will be in the shadow directory, while the source files in the shadow directory are just symlinks to the real files.

This scheme has the advantage that if you update the source, you need not propagate the change to the other architectures by hand, since all source in all shadow directories are symlinks to the real thing: just cd to the shadow directory and recompile away.

The todir argument is optional and defaults to the current directory. The fromdir argument may be relative (e.g., ../src) and is relative to todir (not the current directory).

If you add files, simply run lndir again. New files will be silently added. Old files will be checked that they have the correct link.

Deleting files is a more painful problem; the symlinks will just point into never-never land.


Normally lndir outputs the name of each subdirectory as it descends into it. The -silent option suppresses these status messages. -silent may be abbreviated to -s.

If a file in fromdir is a symbolic link, lndir will make the same link in todir rather than making a link back to the (symbolic link) entry in fromdir. The -ignorelinks option changes this behavior. The link created in todir will point back to the corresponding (symbolic link) file in fromdir. If the link is to a directory, this is almost certainly the wrong thing. The -ignorelinks option may be abbreviated to -i.

If a file in fromdir is a symbolic link to a directory and the -withsymdirs option is specified, lndir will shadow the directory tree the symbolic link points to, whether or not the -ignorelinks is also specified. The -withsymdirs option may be abbreviated to -d.

lndir will remove dangling symbolic links and empty directories in the shadow tree. The -clean option may be abbreviated to -c.

lndir will do the cleaning phase only, not creating the shadow tree. The todir argument may be provided, and defaults to the current directory when not provided.

lndir will normally not shadow any BitKeeper, RCS, SCCS, CVS, CVS.adm and .svn subdirectories, nor any .cvsignore and .gitignore files. This option causes these directories and files to be treated as any other, rather than ignored. -withrevinfo may be shortened to -r.

By default, lndir does not shadow files or directories whose name is .DS_Store, or ._.DS_Store, or starts with '.#', or ends in '~'. This option, which may be abbreviated to -E, causes such files to also be shadowed.

This option adds name to an initially empty list of filenames in fromdir that are not to be shadowed. -except may be specified as -e. This option may be repeated as many times as necessary.


The program displays the name of each subdirectory it enters, followed by a colon. The -silent option suppresses these messages.

A warning message is displayed if the symbolic link cannot be created. The usual problem is that a regular file of the same name already exists.

If the link already exists but doesn't point to the correct file, the program prints the link name and the location to which it does point.

Table of Contents