3

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?

2

3 Answers 3

4

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.

2
  • 1
    what is the difference between replacing this data with empty string, and removing this data? Perhaps I'm missing something here.
    – minto
    Jul 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 with s/pattern/d
    – Bart
    Jul 30, 2019 at 6:39
4

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.

2
  • 1
    personal preference? ;)
    – Bart
    Jul 29, 2019 at 14:04
  • 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
2

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .