Curt Sampson (cjs@cynic.net)
Sun, 20 Feb 2000 19:07:04 -0500 (EST)
On Sun, 20 Feb 2000, jerome schatten wrote:
> All 18 links in the /newpart/usr/lib directory look like:
> filename1.so@ -> ../../filename2.so
> ...
> Is there an easy way of editing these 18 links at one time, or do I have
> to, one at a time, remove the old link and type in the new one?
Well, it's not going to be terribly easy, since there's no non-kludgy
way I know of to reliably get the target of a symlink in Unix. But
the first line of this script does it, assuming you don't have any
filenames with `->' in them, and the rest just links to the same
filenames as the old targets, but in the current directory.
ls -l | sed -n -e 's/.* \([^ ]*\) -> \(.*\)/\1 \2/p' |\
while read link oldtarget; do
newtarget=$(basename $oldtarget)
echo ln -s $newtarget $link
done
Run this as it stands an examine the output carefully. If it looks
as if it's ging to do what you want to do, remove the `echo' command
in the fourth line, and it will actually execute the links.
cjs
-- Curt Sampson <cjs@cynic.net> 917 532 4208 De gustibus, aut bene aut nihil. The most widely ported operating system in the world: http://www.netbsd.org-- This message came to you via the Vancouver Linux Users Group mailing list. For unsubscription instructions do not email the list, but rather send mail to <vanlug-request@gweep.bc.ca>.
This archive was generated by hypermail 2.0b3 on Mon 21 Feb 2000 - 00:09:05