Showing results for 
Search instead for 
Did you mean: 

Modify 250 user .profiles at once.

Regular Advisor

Modify 250 user .profiles at once.

HP-UX 11.0 L2000

We're upgrading from oracle 8i to 9i. I need to modify each user's .profile and softlink it to the appropriate directory where their new .profile is located. I know to use ln -s to create the softlink but does anyone have a script that would automate this process with 5 different .profiles and 250 users. Each user will need to be linked to one of the 5 .profiles.

A. Clay Stephenson
Acclaimed Contributor

Re: Modify 250 user .profiles at once.

This is rather easy with sed, Perl, or awk but rather tha doing symbolic links, let me give you a plan B:

Create your 5 different scripts to set and export the environment variables.

Now each of your user's .profile won't have a symbolic link but rather will source one of these 5 files using the "." dot operator.
. /usr/local/bin/

In the future, all you have to do is make changes to one of these 5 files and nothing else needs to be touched. Also, batch files can source the appropriate file in the same way. Note: These sourced files must mot contain an exit or return statement.
If it ain't broke, I can fix that.
Rodney Hills
Honored Contributor

Re: Modify 250 user .profiles at once.

Clay's idea is the better way. But if you ever wanted to edit a bunch of files, perl has the "-i" option to edit in place. For instance-

perl -i -p -e 's/oracle8/oracle9/g' /home/*/.profile

would change every occurance of text oracle8 to oracle9 in all the .profile files.


-- Rod Hills
There be dragons...