Search code examples
unixsed

Interpret as fixed string/literal and not regex using sed


For grep there's a fixed string option, -F (fgrep) to turn off regex interpretation of the search string. Is there a similar facility for sed? I couldn't find anything in the man. A recommendation of another gnu/linux tool would also be fine.

I'm using sed for the find and replace functionality: sed -i "s/abc/def/g"


Solution

  • You should be using replace instead of sed.

    From the man page:

       The replace utility program changes strings in place in files or on the
       standard input.
    
       Invoke replace in one of the following ways:
    
           shell> replace from to [from to] ... -- file_name [file_name] ...
           shell> replace from to [from to] ... < file_name
    
       from represents a string to look for and to represents its replacement.
       There can be one or more pairs of strings.