sed error "command c expects \ followed by text" under OS X (but works in Linux)
I'm trying to find a line containing the text "foo" and replace that whole line (i.e., the rest of the line as well) with the text "bar". Under Linux, I'm able to use sed like so:
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.
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).
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
BSD May 10, 2005 BSD
|All times are GMT -5. The time now is 08:58 AM.|