I'm using GNU Sed 4.2.1. I'm trying to replace the second field in the following line (the password in /etc/shadow). Awk
is not an option.
username:P@s$w0rDh@$H:15986:0:365::::
I've tried
sed -i 's/\(^[a-z]*\):.*?:/\1:TEST:/'
but nothing. I've tried many variations but for some reason I can't get it to only match that field. Help?
Use [^:]*
to match everything up until the next :
sed -i 's/^\([^:]*\):\([^:]*\):/\1:TEST:/'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments