views:

217

answers:

1

Some servers only support ftp to upload files.

When I export the a project from my subversion repository to my windows machine, all (linux) symlinks are replaces by placeholder-files:

link ../www_public/images

after uploading the all exported files I now use

find | xargs grep -P ^link

to find all those placeholders. I then replace them with the actual symlink manually.

I would really like to automate this step with a shell-script.
How would I do this?

Note:
If there is a better / different solution to this problem, don't hesitate to share it :)

+2  A: 

Here's one possible solution:

:
grep -lr '^link' . | while read placeholderfile
do
  linkfile=`cut -c6- "$placeholderfile"`
  ln -sf "$linkfile" "$placeholderfile"
done

edit: changed code above w.r.t. the comments below.

Bill Karwin
It's probably better to use cut -c6- (paths might have spaces). Also, I don't understand your ln statement. I'd expect something like ln -s "`pwd`/$linkfile" "$placeholderfile". (And possible remove the rm and use ln -sf.) It might also be that this is because I interpreted the question differently.
mweerden
I didn't know for certain that the placeholder file had the same name as the link file. Probably true, but I didn't assume.
Bill Karwin
Yes, the name of the placeholder file is the name of the symlink which is the same as the target name.
Jacco