I'm trying to find and replace multiple directories with symlinks, but I have no idea how to do it.
I have 2 root folders, lets say /var/www/html
and /var/www/html2
and they both contain the same files and folders, for example
/var/www/html/project1/lib/config
/var/www/html2/project1/lib/config
/var/www/html/project2/v1/lib/config
/var/www/html2/project2/v1/lib/config
/var/www/html/project2/v2/lib/config
/var/www/html2/project2/v2/lib/config
What I want to do is search /var/www/html
and replace all config
folders with a symlink to the same folder in /var/www/html2
, but only if config
is inside a lib
folder
I understand that I will have to remove the existing directory (rm -r /var/www/html/project1/lib/config
) and then create the symlink (ln -s /var/www/html2/project1/lib/config /var/www/html/project1/lib/config
)
I can do this manually, but I'd like to create a 1 liner or shell script to do this.
Any help would be greatly appreciated!