Linux.com

Re:Are the backslashes necessary?

Posted by: Anonymous Coward on August 04, 2005 05:56 AM
Unless your post got damaged by text conversion by the posting system, you misquoted the author, who wrote:

sed s/\[///g

Actually, what the author gave won't work properly from the command line either. The shell (bash?) will eat the backslash before sed sees it.

The author probably meant:

sed 's/\[///g'

(The single quotes tell bash not to mess with the contents of the single quotes.)

In this case, the backslash is telling sed not to treat [ as a special character. As the author wrote, if you don't put that in, sed will think that [ means the start of a character range, and will die when it can't find the matching ].

-drane

#

Return to CLI Magic: Regular expressions and metacharacters