Originally posted by hk_linux
This will directly overwrite the /etc/passwd.
Yes ... yes it will ... make sure to get it right the first time
You'll also want the correct shell syntax, which is: perl -pi -e 's#/bin/sh$#/new/path#' /etc/passwd
<-- Single quotes around the -e block avoid having to escape for the shell. If you're uncomfortable editing the passwd file in place, you can use perl -pi.old -e 's#/bin/sh$#/new/path#' /etc/passwd
, which will put the original in /etc/passwd.old.
I posted the long way in case you wanted to do more with the data than sed can do ...
(Note that the '?'s from the last poster and the '#'s in this are completely interchangeable, but '?' is a regex reserved character and makes the search string hideous to read).
If it's jjust one user, why not just vipw
and be done with it?