I have this command:
ln -sf src/* lang/golang/src/genericc/
I want to symlink all the files in src to the existing genericc directory, but when I run the above command I get broken symlinks in the destination. Anyone know how to do this?
I have this command:
ln -sf src/* lang/golang/src/genericc/
I want to symlink all the files in src to the existing genericc directory, but when I run the above command I get broken symlinks in the destination. Anyone know how to do this?
Symlinks created with relative paths (i.e. where the source path doesn't start with "/") get resolved relative to the directory the link is in. That means a link to "src/foo.c" in the lang/golang/src/genericc/ directory would try to resolve to lang/golang/src/genericc/src/foo.c which probably doesn't exist.
Solution: either use an absolute path to the source files, like this:
ln -sf /path/to/src/* lang/golang/src/genericc/
or, to get the *
wildcard to work right with a correct command, cd
to the target directory so the relative paths will work the same way during creation that they will during resolution:
cd lang/golang/src/genericc
ln -sf ../../../../src/* ./
First of all, you can try ln -s $PATH_TO_SRC/* $PATH_TO_TARGET/
.
However, it might have the "Argument list too long error".
Then you can use:
find $PATH_TO_SRC/ -type f -name "*.jpg" -exec cp -s {} . \;
Because if you use ln -s
with find or bash loop, it will only create an empty link. Instead, we can use cp -s
to create a smylink as well.
With the -r
option, ln creates a link to the actual files wherever they are:
ln -srf src/* lang/golang/src/genericc/
© 2022 - 2024 — McMap. All rights reserved.