Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

request perl "one liner" to comment out if "a,b or c"

Posted on 2011-04-25
3
Medium Priority
?
371 Views
Last Modified: 2012-05-11
I want to do an inplace edit if
Line starts with
rlogin or rsh or login

I want to comment the line out

example
rlogin fred
login sally
eat pizza
rsh yada

would become
#rlogin fred
#login sally
eat pizza
#rsh yada

thx








0
Comment
Question by:TIMFOX123
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 35462708
perl -i  -pe 's/^(rlogin|login|rsh)/#$1/' file

Open in new window

0
 
LVL 16

Expert Comment

by:Justin Mathews
ID: 35462758

perl -pi.bak -e 's/^(r?login|rsh)/#$1/' filename

Open in new window

0
 

Author Closing Comment

by:TIMFOX123
ID: 35465020
this work  

thx
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question