Re: Insert character x at...
Tim Chase <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 2013-05-16 11:59, Aurelio Jargas wrote:
> On Thursday, May 16, 2013, Tim Chase wrote:
> > For the original request:
> >
> > sed '/^0530/s/\(.\{31\}/\1x/' input.txt
Doh, I missed the closing "\)" in there. Should have been
sed '/^0530/s/\(.\{31\}\)/\1x/' input.txt
which could have been reduced in this particular case to
sed '/^0530/s/.\{31\}/&x/' input.txt
> One alternative to insert a char after a column N is to use the
> numeric flag in the s command.
>
> $ echo 123456789 | sed 's/./&x/5'
> 12345x6789
But that's pretty slick. I don't often recall the /{number} flag, as
vi/vim doesn't offer it, so I don't have as much occasion to use it.
-tim