instead of escaping find -exec

Found myself setting up quite a few symlinks in one of our repos at work today. It all followed a simple pattern where a current link was set up to point to to folders with a particular name. The link was to be setup in multiple places in the folder structure.

So, quickly started typing out a find -exec command but the escaping got really messy quickly. After some tinkering I ended up piping the find output to a while read loop that did the work. And I did not have to worry about escaping.

find -name needle | while read dir; do
  ( cd `dirname $dir`; ln -s needle current-special )