sed replacing a string in a file
Simple example of replacement of a password field in /etc/shadow. usern=robbie encpass= :$1$CQoPk7Zh$370xDLmeGD9m4aF/ciIlC sed -i "s/^${usern}\:[^\:]\{1,100\}\:/${usern}\:${encpass}\:/" /etc/shadow Probably some more improvements here (e.g. determine maximum hashed password string length rather than "up to 100"…