I trying to replace password in a simple password file. The new password is garbage and is randomly generated.
For example here is a shadow file with the root account.
root:igXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+udyyyyyyyyyyyySgY=:10933:0:99999:7::: I have the following expression which works 3 out of 4 try.
On the fourth try, I get this error "sed: bad option in substitution expression".
The other time, it works just fine. The password is replaced with a randomly generate string.
sed -i "/root/ s/ *:[^:]*:/:"$(openssl rand -base64 32)":/ " shadow Can some one please help explain the problem?
Thanks, Tai