sed + mark line in case of marched word

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
-1
down vote
favorite
we want to mark with "#" the matched line by sed or perl line liner
for example
we want to mark all lines in file that include the DatePattern word
log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
expected output
#log4j.appender.DRFA.DatePattern
note - in case line already marked then it will not add another "#" before the line
linux text-processing sed logs perl
add a comment |Â
up vote
-1
down vote
favorite
we want to mark with "#" the matched line by sed or perl line liner
for example
we want to mark all lines in file that include the DatePattern word
log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
expected output
#log4j.appender.DRFA.DatePattern
note - in case line already marked then it will not add another "#" before the line
linux text-processing sed logs perl
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
we want to mark with "#" the matched line by sed or perl line liner
for example
we want to mark all lines in file that include the DatePattern word
log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
expected output
#log4j.appender.DRFA.DatePattern
note - in case line already marked then it will not add another "#" before the line
linux text-processing sed logs perl
we want to mark with "#" the matched line by sed or perl line liner
for example
we want to mark all lines in file that include the DatePattern word
log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
expected output
#log4j.appender.DRFA.DatePattern
note - in case line already marked then it will not add another "#" before the line
linux text-processing sed logs perl
edited yesterday
Jeff Schaller
30.7k846104
30.7k846104
asked yesterday
yael
1,786940
1,786940
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Prepending # to the line and also removing the = and whatever comes after it:
sed 's/^([^#].*DatePattern)=.*/#1/' file
Alternatively, not removing the =:
sed 's/^[^#].*DatePattern/#&/' file
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
add a comment |Â
up vote
1
down vote
In case you don't want to remove the trailing date pattern (your spec is not quite clear), try
sed '/^[^#].*DatePattern/ s/^/#/' file
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Prepending # to the line and also removing the = and whatever comes after it:
sed 's/^([^#].*DatePattern)=.*/#1/' file
Alternatively, not removing the =:
sed 's/^[^#].*DatePattern/#&/' file
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
add a comment |Â
up vote
1
down vote
accepted
Prepending # to the line and also removing the = and whatever comes after it:
sed 's/^([^#].*DatePattern)=.*/#1/' file
Alternatively, not removing the =:
sed 's/^[^#].*DatePattern/#&/' file
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Prepending # to the line and also removing the = and whatever comes after it:
sed 's/^([^#].*DatePattern)=.*/#1/' file
Alternatively, not removing the =:
sed 's/^[^#].*DatePattern/#&/' file
Prepending # to the line and also removing the = and whatever comes after it:
sed 's/^([^#].*DatePattern)=.*/#1/' file
Alternatively, not removing the =:
sed 's/^[^#].*DatePattern/#&/' file
edited yesterday
answered yesterday
Kusalananda
100k13199311
100k13199311
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
add a comment |Â
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
do you have another suggestion from my question on - unix.stackexchange.com/questions/460642/â¦
â yael
yesterday
add a comment |Â
up vote
1
down vote
In case you don't want to remove the trailing date pattern (your spec is not quite clear), try
sed '/^[^#].*DatePattern/ s/^/#/' file
add a comment |Â
up vote
1
down vote
In case you don't want to remove the trailing date pattern (your spec is not quite clear), try
sed '/^[^#].*DatePattern/ s/^/#/' file
add a comment |Â
up vote
1
down vote
up vote
1
down vote
In case you don't want to remove the trailing date pattern (your spec is not quite clear), try
sed '/^[^#].*DatePattern/ s/^/#/' file
In case you don't want to remove the trailing date pattern (your spec is not quite clear), try
sed '/^[^#].*DatePattern/ s/^/#/' file
answered yesterday
RudiC
612
612
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460645%2fsed-mark-line-in-case-of-marched-word%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password