Oops, I mis-read the original post.
If it was a one-time thing, I would probably generate a script from the ls -l output, check the script and then execute it. For example:
Code:
cd /etc/alternatives
ls -l | grep postgresql | sed 's!postgresql/8.1!postgresql/8.2!' | awk '{ print "update-alternatives --set " $8 " " $10 }' > /tmp/alt_updater
and check that /tmp/alt_updater contains commands which work, and that it affects the right items, and then execute it using:
Code:
sudo bash /tmp/alt_updater
I used postgres in my example because I don't have the java stuff installed. It should e easy to modify for your purposes.
One last thing - I didn't check that I'm using the correct syntax for update-alternatives - I always use galternatives. Do a test first!