sed error "command c expects \ followed by text" under OS X (but works in Linux)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Bash is the default shell on most versions of UNIX, including Mac OS X and many Linux distributions.
Bash treats a backslash at the end of the line as a line continuation character, even inside double-quoted strings. So when bash executes sed, it doesn't pass the newline character or the backslash.
You have two options. You can change your shell (use "echo $SHELL" under Linux to see which shell you are using) to make both environments the same, or you could change the way you quote the input. You could double up the backslash, which will cause the first backslash to escape the second rather than the newline, making it to pass a single backslash and the newline to the shell, or you could use single-quotes around the -e parameter to treat it as a literal string without any substitutions (including backslash escapes, backticks, variable substitution, and so on).
Distribution: RH5.2, RH6.2, RH8.0, RH 9.0, RHEL 3.0,MDK 10.1, KNOPPIX3.6, Solaris 8, Solaris 9, CentOS 3x-4x-5x, U
Originally Posted by David the H.
It looks like your backslash is getting gobbled up somehow, so that it disappears before getting passed to sed. Try enclosing your expression in single quotes, and/or escaping the backslash.
GNU version of sed works fine
BSD implementation of sed has few not resolved issues
taken from Mac OSX man sed pages
A sed command, written by L. E. McMahon, appeared in Version 7 AT&T UNIX.
Diomidis D. Spinellis <dds@FreeBSD.org>
Multibyte characters containing a byte with value 0x5C (ASCII `\') may be incorrectly treated as line continuation characters
in arguments to the ``a'', ``c'' and ``i'' commands. Multibyte characters cannot be used as delimiters with the ``s'' and