What does ,^@ means in a sed expression
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I came across this code sed ',^@, s/ABC/XYZ/' filename
What does ,^@,
means here. I thought comma ,
operator defines the line range on which substitute expression will operate.
sed
add a comment |Â
up vote
3
down vote
favorite
I came across this code sed ',^@, s/ABC/XYZ/' filename
What does ,^@,
means here. I thought comma ,
operator defines the line range on which substitute expression will operate.
sed
,
means,
is regex delimiter instead of usual/
...^@
to match@
at beginning of line...,
to end the match...s/ABC/XYZ/
to perform substitutions only on lines matching@
at beginning of line...
â Sundeep
Apr 11 at 13:26
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
@CppLearner for substitute commands,s,foo,baz,
will work.. but for address matching, you need extraat start...
â Sundeep
Apr 11 at 14:30
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I came across this code sed ',^@, s/ABC/XYZ/' filename
What does ,^@,
means here. I thought comma ,
operator defines the line range on which substitute expression will operate.
sed
I came across this code sed ',^@, s/ABC/XYZ/' filename
What does ,^@,
means here. I thought comma ,
operator defines the line range on which substitute expression will operate.
sed
edited Apr 11 at 14:30
don_crissti
46.4k15123152
46.4k15123152
asked Apr 11 at 13:21
CppLearner
3481212
3481212
,
means,
is regex delimiter instead of usual/
...^@
to match@
at beginning of line...,
to end the match...s/ABC/XYZ/
to perform substitutions only on lines matching@
at beginning of line...
â Sundeep
Apr 11 at 13:26
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
@CppLearner for substitute commands,s,foo,baz,
will work.. but for address matching, you need extraat start...
â Sundeep
Apr 11 at 14:30
add a comment |Â
,
means,
is regex delimiter instead of usual/
...^@
to match@
at beginning of line...,
to end the match...s/ABC/XYZ/
to perform substitutions only on lines matching@
at beginning of line...
â Sundeep
Apr 11 at 13:26
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
@CppLearner for substitute commands,s,foo,baz,
will work.. but for address matching, you need extraat start...
â Sundeep
Apr 11 at 14:30
,
means ,
is regex delimiter instead of usual /
... ^@
to match @
at beginning of line... ,
to end the match... s/ABC/XYZ/
to perform substitutions only on lines matching @
at beginning of line...â Sundeep
Apr 11 at 13:26
,
means ,
is regex delimiter instead of usual /
... ^@
to match @
at beginning of line... ,
to end the match... s/ABC/XYZ/
to perform substitutions only on lines matching @
at beginning of line...â Sundeep
Apr 11 at 13:26
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
@CppLearner for substitute commands,
s,foo,baz,
will work.. but for address matching, you need extra
at start...â Sundeep
Apr 11 at 14:30
@CppLearner for substitute commands,
s,foo,baz,
will work.. but for address matching, you need extra
at start...â Sundeep
Apr 11 at 14:30
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
According to the man
page, In a context address, the construction "cBREc", where c is any character other than backslash or newline, shall be identical to "/BRE/". So your script is identical to
sed '/^@/ s/ABC/XYZ/' filename
which means the replacement is only to be done in lines starting with @
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
According to the man
page, In a context address, the construction "cBREc", where c is any character other than backslash or newline, shall be identical to "/BRE/". So your script is identical to
sed '/^@/ s/ABC/XYZ/' filename
which means the replacement is only to be done in lines starting with @
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
add a comment |Â
up vote
4
down vote
accepted
According to the man
page, In a context address, the construction "cBREc", where c is any character other than backslash or newline, shall be identical to "/BRE/". So your script is identical to
sed '/^@/ s/ABC/XYZ/' filename
which means the replacement is only to be done in lines starting with @
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
According to the man
page, In a context address, the construction "cBREc", where c is any character other than backslash or newline, shall be identical to "/BRE/". So your script is identical to
sed '/^@/ s/ABC/XYZ/' filename
which means the replacement is only to be done in lines starting with @
According to the man
page, In a context address, the construction "cBREc", where c is any character other than backslash or newline, shall be identical to "/BRE/". So your script is identical to
sed '/^@/ s/ABC/XYZ/' filename
which means the replacement is only to be done in lines starting with @
edited Apr 11 at 14:23
Kusalananda
102k13199316
102k13199316
answered Apr 11 at 14:20
Philippos
5,90211545
5,90211545
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
add a comment |Â
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
Perfect Philippos. This is what I was looking for thanks a lot for your help and explanation. Upvoting and accepting this as answer. Thank you.
â CppLearner
Apr 11 at 15:25
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%2f437016%2fwhat-does-means-in-a-sed-expression%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
,
means,
is regex delimiter instead of usual/
...^@
to match@
at beginning of line...,
to end the match...s/ABC/XYZ/
to perform substitutions only on lines matching@
at beginning of line...â Sundeep
Apr 11 at 13:26
see also: stackoverflow.com/questions/5864146/use-slashes-in-sed-replace
â Sundeep
Apr 11 at 13:27
Thanks Sundeep, sorry but I am still not clear. I understood ^@ denotes lines starting with @. Are you saying , means alternate regex delimeter , then shouldn't it be just ,@, or ,@,. Thanks
â CppLearner
Apr 11 at 13:46
see Find the line [...] using custom regex delimiter
â don_crissti
Apr 11 at 14:29
@CppLearner for substitute commands,
s,foo,baz,
will work.. but for address matching, you need extraat start...
â Sundeep
Apr 11 at 14:30