some kind of binary sed(1) command
Nikos Vassiliadis
nvass at gmx.com
Thu Feb 2 10:29:32 UTC 2012
On 2/2/2012 8:22 AM, Matthias Apitz wrote:
>
> Hello,
>
> I have a normal ASCII file wich has in some places two lines of '*',
> separated by an empty line, i.e.
>
> ....\n
> *********************\n
> \n
> *********************\n
> ....\n
>
> and I want to substitute the \n between the star lines by \f; the
> 'binary' sed command would just be
>
> s/*****\n\n*****/*****\n\f*****/
>
> which ofc does not work with sed(1) because it is line oriented;
> I could write something in perl, C, awk or whatever language, but I
> would prefer to do it with the normal commands... any ideas?
>
> Thanks
>
> matthias
Perhaps, something like this:
> raidmadi% sed '/\*\*\*\*/{ N;N;s/\(\*\*\*\*\n\)\(\n\)\(\*\*\*\*\)/\1\\f\
> \3/; }; '
> ****
>
> ****
> ****
> \f
> ****
> ****
> foo
> ****
> ****
> foo
> ****
Keep in mind that I am using zsh which allows you to write multi-line
commands.
HTH, Nikos
More information about the freebsd-questions
mailing list