On 09Nov2017 13:37, Patrick Dupre <pdu...@gmx.com> wrote:
>        I would like to execute a vi command as a bash command like:
>        vi +:1 "+1,$s/E/e/g" "+wq"  test.TXT
>        But it does not work!
>
>        under vi, I would do:
>        vi test.TXT
>        :1
>        :1,$s/E/e/g
>        :wq
>
>        could you tell me what I am missing?

This is why you should always use single quotes (') instead of double quotes
(") unless there is some reason not to, such as _wanting_ to substitute a shell
variable into a string.

As an aside, is there a reason you want to use vi for this instead of something
like sed?

Can I make 2 substitutions on a single call with sed?

Of course! You can write whole programs in sed. It is extremely useful.

 sed -i s/E/e/g test.TXT

The -i is a GNU-sed extra for pretend in place editing; it makes a temp file with the changes then renames that to the original. That makes for an atomic change, but means the changed file is a new one, not a rewritten old one.

"sed" is short for stream editor, it normally lives in a shell pipeline to modify data passing through it. It has the ed command set plus some extra things.

Those edit commands you use after ":" in vim? They are based on the ed command set too.

Cheers,
Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au)
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to