What is the meaning of sed command sed -i 's,-m64,,g' Makefile
?
Does it simply remove -m64
argument from Makefile?
Is it the same with sed -i 's/-m64//g' Makefile
,
just use /
delimiter in place of commas?
-
Also related: How can I achieve portability with sed -i (in-place editing)? and Using sed with special characters– Kusalananda ♦Jul 29, 2019 at 16:00
-
Related from SO: Using different delimiters in sed commands and range addresses– StoborJul 30, 2019 at 2:13
3 Answers
Yes, it's the same as with /
delimiter. Sometimes you may use different delimiters not to confuse sed
.
In this case, you replace all -m64
instances with empty string, not remove as such.
See this resource on using delimiters in sed
.
-
1what is the difference between replacing this data with empty string, and removing this data? Perhaps I'm missing something here.– mintoJul 29, 2019 at 18:20
-
in our terms, the same. with sed, a little different in terms of syntax. you replace with
s/pattern1/pattern2/g
and delete withs/pattern/d
– BartJul 30, 2019 at 6:39
Is it the same with
sed -i 's/-m64//g' Makefile
Yes it is the same, any character can be used as the sed
delimiter. You would usually do this when one of the strings contains the delimiter character, I don't know why the person who made that command decided to use a comma as a delimiter in this case.
-
1
-
1@Bart yes possibly I suppose, I was thinking it was a really arbitrary choice of character but I've just realised that commas are obviously used to separate arguments to functions in programming languages so that's probably why someone would choose it. Jul 29, 2019 at 14:09
Yes. You can use any delimiter you like.
Please see this tutorial for more info...
The -m64 will be replaced with nothing, so yes, it does remove it. Since you have a "g" at the end, this will be globally in the document.