I have a ghc directory containing ghci.conf:

$ tree ghc                                                                                                 
└── ghci.conf

0 directories, 1 file

And I want to create symbolic link at $HOME/.ghc, but the latter directory contains other files and directories.

When doing:

$ ln -s -f ghc ~/.ghc

I get a symbolic link to my ghc under $HOME/.ghc, which is not what I intended:

$ ls -l ~/.ghc                                                                                                                
total 16
lrwxr-xr-x  1 jviotti  staff    41 Nov 30 20:40 ghc -> /Users/jviotti/dotfiles/link/ghc
-rw-r--r--  1 jviotti  staff  1883 Nov 30 20:34 ghci_history
drwxr-xr-x  3 jviotti  staff   102 Jul  9 13:35 x86_64-darwin-7.6.3
drwxr-xr-x  3 jviotti  staff   102 Nov 11 13:51 x86_64-darwin-7.8.3

A quick solution do accomplish this would be to iterate trough the contents of ghc and execute ln -s on each file, however I was wondering if there is an easier way to instruct ls to merge the files automatically of trying to create a symbolic link to a directory from an existing directory.

Does such option exist?


Forgive me if a misunderstand the question, but is 'rsync' an option to get the directories in sync and THEN recreating the symlink you want?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.