Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
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...