How do I symlink each of the files in one directory to another directory?
You can use (GNU) cp
with the --symbolic-link
option:
prompt$ mkdir foo
prompt$ cd foo
prompt$ touch a b c
prompt$ mkdir ../bar
prompt$ cd ../bar
prompt$ cp --symbolic-link ../foo/* .
prompt$ ls -l
total 0
lrwxrwxrwx. 1 hlovdal hlovdal 8 Jun 12 16:24 a -> ../foo/a
lrwxrwxrwx. 1 hlovdal hlovdal 8 Jun 12 16:24 b -> ../foo/b
lrwxrwxrwx. 1 hlovdal hlovdal 8 Jun 12 16:24 c -> ../foo/c
prompt$
Give this a try:
ln -s /foo/* /bar
The source directory, as specified in the question, is /foo
. Note that it must be fully specified (i.e. starting at the root directory), so other examples would look like this:
ln -s /some/dir/with/baz/* destdir
ln -s /dir/to/link/from/* /dir/to/link/to
ln -s $PWD/stuff/* more/stuff
Something like this?
cd /foo
for f in *; do ln -s $PWD/$f /bar; done