Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Is this possible to make a one liner?

by mpd (Monk)
on Aug 02, 2003 at 00:42 UTC ( #280199=note: print w/replies, xml ) Need Help??


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."

Replies are listed 'Best First'.
Re: Re: Is this possible to make a one liner?
by Grygonos (Chaplain) on Aug 02, 2003 at 06:53 UTC
    thanks guys.. answered my question beautifully.. i'm still trying to learn more about this slick kind of perl scripting

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://280199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2021-11-28 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?