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.

Say I have a bunch of config files that I'd like to store elsewhere, but if I move them and then symlink the directory, the application sees it as a symlink and won't use the contained files.

Instead what I'd like to do is figure out a command that would allow me to batch-create symlinks for all of the files within a given directory. Can this be done?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Just use a wildcard. Like this:

ln -s /path/to/config/files/* /path/to/symlinks/

While you can use a relative path for the destination directory, the directory the link targets are in must be specified with an absolute path.

Note that if there are any directories in the directory with the targets, it will make a symlink to it instead of creating a directory with symlinks inside. If there are too many (if any at all) to work around manually you'd have to write a shell script to accomplish this.

share|improve this answer
    
If you have too many files look into the "xargs" command. –  Chris Nava Mar 6 '11 at 22:36
    
Wow, now I feel silly for asking! Simple, elegant, and probably something I could have guessed in about 10 minutes! Thanks! –  Wilco Mar 6 '11 at 23:13
    
@Wilco: We all have those moments. Rubber ducky debugging anyone?? –  surfasb Jan 17 '12 at 21:58

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.