1

I have two computers, lets call them movies and else, and I would like to symbolically merge files from else into movies.

In //movies/usr/local/sbin I have:

script1 and script2.

and in //else/usr/local/sbin I have:

scripta and scriptb.

When listing files on movies I'd like to see all 4 scripts, however when on else I do not want to see the scripts on movies.

Is there a simple way to create a symlink for this?

Thanks, Mark.

troylatroy
  • 1,275
  • 1
  • 11
  • 21
Cool Javelin
  • 196
  • 6

1 Answers1

1

I assume you already have a network share set up such that you can see the else structure from movies. In that case, you can do something like:

movies:~$ sudo ln -s /path/to/else/usr/local/sbin/scripta /usr/local/sbin/scripta
movies:~$ sudo ln -s /path/to/else/usr/local/sbin/scriptb /usr/local/sbin/scriptb

Then, you'll be able to see scripta and scriptb from your movies computer, but not anything from movies in else.

Note that you'll have to do an ln command for each file you want to symlink - it wouldn't be safe to try to symlink the entire directory contents.

rmbri
  • 51
  • … but you can do this for multiple files simply with a for loop, e. g. for all files in the current directory with for f in *; do ln -s /path/to/else/$f $f; done. – dessert Aug 30 '17 at 20:44
  • "it wouldn't be safe to try to symlink the entire directory contents" can you please elaborate more on this concept? Why not safe? and if it can be done, how to do. I'd like to experiment a bit. – Cool Javelin Aug 31 '17 at 18:19
  • You would overwrite contents in the target directory. For example on "movies" if you had /usr/local/sbin/myscript and on "else" you had /usr/local/sbin/myscript, if you symlinked everything, you'd overwrite the version on "movies".

    However, if /usr/local/sbin is empty on "movies", or if you know there is no overlap, then dessert's suggestion would work for you.

    – rmbri Sep 01 '17 at 02:51