SED TIPS


  • In order to replace a word with a newline and some other text:

    1,$s/Mode/Mode,\\^M UpdateMinMaxDb=1, OverWrite=1, HxRG=SHxRG/g


    where Mode is the word you want to replace. To get the ^M, hold down Ctrl-V and press m


  • To replace a set of characters with the same characters (along with additional ones):

    1,$s/Mode[...]/&/g


    where Mode and the three charcters following it is the expression you want to replace. & will contain Mode+the 3 additional characters that follow it.
  • To replace the first character in each line with 2 spaces:

    1,$s/^/ \ /


    If more spaces are desired, one can add that number of '\ ' after the last '\ ' in the line.
  • To insert '||' at column 33:

    1,$s/^(.\{33\}\)/\1||/g


    The \(...\)) indicates this is a group.
    The group consists of 33 instances (\{33\}) of any character (.) starting at the beginning of the line (^).
    The (\1) replaces the group with itself.
  • SED does not recognize '\t' so use an actual stroke of the TAB key instead