Avatar of David Aldridge
David Aldridge
Flag for United States of America

asked on 

Replacing words in a line of a file.

replacing parts of a line in a file (/etc/group).

If I have the following line in my group file, I want to remove all of the "sdb" entries, but leave anything else.  For instance:

sdba::1014:sdb,sdb,david,sdb

would need to be changed to:

sdba::1014:david

I'm trying to do this with perl -pi -e if I can.  This SORT of gets me there, but removes the "david" entry.

egrep "^sdba:" $TEMP && perl -pi -e "s/^sdba::.*/sdba::1014:/g" $TEMP

Thanks!
David
Perl

Avatar of undefined
Last Comment
tel2

8/22/2022 - Mon