http://qs321.pair.com?node_id=280199


in reply to Is this possible to make a one liner?

Well, assuming the asker wants an answer written in Perl (this isn't unixmonks.org or shellscriptmonks.org) I'll give it a shot. The given code and the description don't seem to match. A one liner for the ACTUAL CODE GIVEN (i.e. will remove every occurance of } in the file):

perl -i.old -pe 's/}//g;' memgrp.dat

If you just want to remove } when it occurs at the end of the line, just change the regexp to something like s/}(\s*)$/$1/g
You might need to use double quotes on windows.

This will overwrite memgrp.dat with the new information, backing the old one up in memgrp.dat.old (see perlman:perlrun.) This may not be exactly what you want, but it's easy to massage so you get what you're looking for.

This code has been lightly tested and "it works for me."