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

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








TIMFOX123Asked:
Who is Participating?
 
TintinConnect With a Mentor Commented:
perl -i  -pe 's/^(rlogin|login|rsh)/#$1/' file

Open in new window

0
 
Justin MathewsCommented:

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

Open in new window

0
 
TIMFOX123Author Commented:
this work  

thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.