R
R
refsurf2018-12-19 13:32:17
bash
refsurf, 2018-12-19 13:32:17

Script to massively create symlinks by mask?

Essence of the question. There are folders conditionally "a" "b" "c" "d" in folder a there is a folder "x" you need to create a symlink to it in folders "b" "c" "d" (conditionally, actually there are 1kk folders) I do it
on bash (himself a humanist)

#!/bin/bash
ln -s /var/www/a/x /var/www/b
ln -s /var/www/a/x /var/www/c
ln -s /var/www/a/x /var/www/d

Such a script with a million lines is a huge crutch. Perhaps there is a shorter and simpler solution. I can't code at all.
There already exists a million folders. The names are different without any connection between them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2018-12-19
@saboteur_kiev

Change /file to your preferred name
Test (do not apply)
Run

find /var -maxdepth 1 -type d -exec ln -s /var/www/a/x {}/file \;

C
chupasaurus, 2018-12-19
@chupasaurus

root_dir=/var/www
source_root=a
source_dir=x
for dir in $(find $root_dir -mindepth 1 -maxdepth 1 -type d | egrep -v "^root_dir/$source_root\$")
do
  ln -s "$root_dir/$source_root/$source_dir" "$dir/$source_dir"
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question