in reply to in place editing by variables
I have not been sys admin for a UNIX box for a long time. To me it seems dangerous to edit the passwd file with a script like yours. As a minimum I would ask for "use strict;" in the script. Also, there is a number of modules on CPAN to edit the passwd file in a controlled manner, e.g. Unix::PasswdFile among others.
If your aim is to learn how to do things yourself, then I would think that the passwd file is not the best object for that.
UPDATE: Here is a sample script.
my $pw = new Unix::PasswdFile "passwd"; # for real this should be /et +c/passwd or similar $pw->shell( "user1", "/bin/nologin" ); $pw->commit(".bak");
|
|---|