Q. I want to write a 2 line program that lets me substitute "the" with "zee" and "The" with "Zee".

Here is what I'm doing:

I'm writing a sed program for example, program.sed. Inside it, I'm writing

s/the/zee/ \\

Then I'm running program.sed like this

sed -f program.sed otherfilename       


Unfortunately, error occurs, saying command garbled: s/the/zee/g

NOTE: If I do change text c\\ in sed with any other commands etc. it works fine, but the problem is with substitution like for example in the above question.


The down solution worked for me the first one before Or, but not the second one. Maybe because the gator version is pretty old. "Oracle Corporation SunOS 5.10 Generic Patch January 2005". sed version is very old also "23 July 1998". Just wanted others know.

  • @don_crissti, before posting here I even tried that, but it gives the same error.
    – Anonymous
    Commented Jul 22, 2016 at 9:27
  • 1
    @GhostRider which sed version are you using? I tried @don_crissti's suggestion on sed (GNU sed) 4.2.2 and it worked fine
    – Sundeep
    Commented Jul 22, 2016 at 9:31
  • In your note, you mention using c\\ , but your example code only contains \\ . Which is correct, and what do you think that should do? Commented Jul 22, 2016 at 9:58
  • @GhostRider which sed version are you using? I can not see how you get that error for that input. (s/the/zee/g does not appear in input) Commented Jul 22, 2016 at 10:09
  • 1
    do add that info in your question so that it is useful for users visiting this thread.. also add the output of sed --version if it is available (or perhaps available in man sed
    – Sundeep
    Commented Jul 22, 2016 at 16:42

1 Answer 1


In your program.sed you should have:

s/the/zee/g; s/The/Zee/g


  • @StéphaneChazelas thanks for completing my answer mate. I appreciate.
    – user172564
    Commented Jul 22, 2016 at 9:51
  • 1
    The first solution above Or worked for me, but the second one did not. Just wanted other's know. Thanks a lot.
    – Anonymous
    Commented Jul 22, 2016 at 16:47
  • 1
    @GhostRider My pleasure mate. Thanks for letting us know.
    – user172564
    Commented Jul 22, 2016 at 16:49

You must log in to answer this question.

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