I tried replacing 30 chars from the beginning of each line of my text, but could not figure out how to specify to vi sed to do it.

I tried this:


But it could not find my pattern. I thought {3} would mean 3 times the previous, but unfortunately not. { is not interpreted as a regex command but as a search char.

could anyone help?

2 Answers 2


If you look at :h magic:


after:    \v       \m       \M       \V         matches 
                'magic' 'nomagic'
          $        $        $        \$         matches end-of-line
          .        .        \.       \.         matches any character
          *        *        \*       \*         any number of the previous atom
          ~        ~        \~       \~         latest substitute string
          ()       \(\)     \(\)     \(\)       grouping into an atom
          |        \|       \|       \|         separating alternatives
          \a       \a       \a       \a         alphabetic character
          \\       \\       \\       \\         literal backslash
          \.       \.       .        .          literal dot
          \{       {        {        {          literal '{'
          a        a        a        a          literal 'a'

The default node in regular expressions is \m (just magic), so you need to use \{ for the brace to seen as an operator:

                                        /\{ E58 E60 E554 E870
\{n,m}  Matches n to m of the preceding atom, as many as possible
\{n}    Matches n of the preceding atom
\{n,}   Matches at least n of the preceding atom, as many as possible
\{,m}   Matches 0 to m of the preceding atom, as many as possible


  • Thanks! This works for me under Linux , but not AIX. btw nothig with :h magic on my systems.
    – J. Chomel
    Apr 8, 2016 at 9:33
  • 1
    under AIX it says Invalid character in interval expression ; but if I escape the second one, it works.
    – J. Chomel
    Apr 8, 2016 at 9:36

In AIX vi, this will be:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.