w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Symlink directory tree to one directory

This should do it:

cd Directory; find * -type f -print0 | xargs -l -0 bash -c
'filename=`echo "$0" | tr '/' -`; ln -s $(pwd)/$0
../DirectoryDest/$filename'

This will result in these files:

user@machine:~$ ls -l DirectoryDest/
total 0
lrwxrwxrwx 1 user user 51 Jul 27 23:02 DirectoryA-DirectoryAA-FileAA1 ->
/home/user/Directory/DirectoryA/DirectoryAA/FileAA1
lrwxrwxrwx 1 user user 51 Jul 27 23:02 DirectoryA-DirectoryAA-FileAA2 ->
/home/user/Directory/DirectoryA/DirectoryAA/FileAA2
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryA-FileA1 ->
/home/user/Directory/DirectoryA/FileA1
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryA-FileA2 ->
/home/user/Directory/DirectoryA/FileA2
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryB-FileB1 ->
/home/user/Directory/DirectoryB/FileB1
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryC-FileC1 ->
/home/user/Directory/DirectoryC/FileC1
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryC-FileC2 ->
/home/user/Directory/DirectoryC/FileC2
lrwxrwxrwx 1 user user 38 Jul 27 23:02 DirectoryC-FileC3 ->
/home/user/Directory/DirectoryC/FileC3




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.