I have a large file with links beeing created.
f.e.
ln -s ../AAA2/myfile.txt ../dir1/dir2/dir3/dir4/mylink.ln
unfortunately the destination directory structure is not created yet. Is there a way to force the directories (here dirX ) beeing created before the link is created?
Thanks
It's not ln
's job to create directories; that's mkdir
's job.
dest=../dir1/dir2/dir3/dir4/mylink.ln
mkdir -p "${dest%/*}"
ln -s ../AAA2/myfile.txt "$dest"