Skip to main content
1 of 2
Ali Sh
  • 25
  • 1
  • 6

How to execute ln on find results

I want to make symlinks for image files in a directory in the server. Currently I'm doing it by executing this command using php function exec():

ln -sf path/to/source path/to/symlink

Both file names are the same.

And it's working greatly. In the next step I want to make symlinks for other sizes of that particular image which are stored alongside the original image. I searched and find this link: Execute a command on find results which explains to use this format:

find ... -execdir rm {} \;

Now the furthest I got is to list files (full path) using find with the proper regex. But I have no idea how to use this output and link each file to the exact name in target directory.

P.S.: I only have access to the original image and its path.

Ali Sh
  • 25
  • 1
  • 6