On Wed, 11 Aug 2004, Simon Bowden wrote:
Possibly only lowercase relative links:
if [ -L "$file" -a "${file:0:1}" != "/" ]; then
...
Oops, I'm going to be pedantic. This should be:
mv "$file" "$newname"
if [ -L "$file" ]; then
target=$(ls -l "$file" | sed 's/^.* -> //'
if [ "${target:0:1}" != "/" ]; then
newtarget=$(echo "$target" | tr A-Z a-z)
ln -sf "$newtarget" "$newname"
fi
fi
Since $file is the symlink name, not the target name.
Extra pedant - I also realised we should use a raw read:
find ... | while read -r file ; do ...
since then the filenames with backslash escapes in them (which probably
wouldn't be there, but still...).
Errr, k, nuff now :) Fun with shell.
Cheers,
- Simon
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html