Hello,
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?
Thank
=========================================================================== Patrick DUPRÉ | | email: pdupre@gmx.com Laboratoire de Physico-Chimie de l'Atmosphère | | Université du Littoral-Côte d'Opale | | Tel. (33)-(0)3 28 23 76 12 | | Fax: 03 28 65 82 44 189A, avenue Maurice Schumann | | 59140 Dunkerque, France ===========================================================================
is the first +:1 enclosed in ""'s?
---
Regards,
Kevin Martin
On Wed, Nov 8, 2017 at 4:40 PM, Patrick Dupre pdupre@gmx.com wrote:
Hello,
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?
Thank
============================================================
Patrick DUPRÉ | | email: pdupre@gmx.com Laboratoire de Physico-Chimie de l'Atmosphère | | Université du Littoral-Côte d'Opale | | Tel. (33)-(0)3 28 23 76 12 | | Fax: 03 28 65 82 44 189A, avenue Maurice Schumann | | 59140 Dunkerque, France ============================================================ =============== _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org
technically, I guess, based on the man page, it doesn't need to be, but you may want to try that (I assume that your VI is, in fact, VIM).
---
Regards,
Kevin Martin
On Wed, Nov 8, 2017 at 4:45 PM, kevin martin ktmdms@gmail.com wrote:
is the first +:1 enclosed in ""'s?
Regards,
Kevin Martin
On Wed, Nov 8, 2017 at 4:40 PM, Patrick Dupre pdupre@gmx.com wrote:
Hello,
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?
Thank
============================================================
Patrick DUPRÉ | | email: pdupre@gmx.com Laboratoire de Physico-Chimie de l'Atmosphère | | Université du Littoral-Côte d'Opale | | Tel. (33)-(0)3 28 23 76 12 | | Fax: 03 28 65 82 44 189A, avenue Maurice Schumann | | 59140 Dunkerque, France ============================================================ =============== _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org
On 08Nov2017 23:58, Patrick Dupre pdupre@gmx.com wrote:
Actually, the issue is with the $
[...]
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?
Cheers, Cameron Simpson cs@cskk.id.au (formerly cs@zip.com.au)
Sent: Thursday, November 09, 2017 at 4:50 AM From: "Cameron Simpson" cs@cskk.id.au To: "Community support for Fedora users" users@lists.fedoraproject.org Subject: Re: vi
On 08Nov2017 23:58, Patrick Dupre pdupre@gmx.com wrote:
Actually, the issue is with the $
[...]
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?
Cheers, Cameron Simpson cs@cskk.id.au (formerly cs@zip.com.au) _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org
On 09Nov2017 13:37, Patrick Dupre pdupre@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 cs@cskk.id.au (formerly cs@zip.com.au)
On Fri, 10 Nov 2017 15:58:56 +0100, Dario Lesca wrote:
Il giorno gio, 09/11/2017 alle 13.37 +0100, Patrick Dupre ha scritto:
Can I make 2 substitutions on a single call with sed?
Two or more ...
$ sed -i -e 's/E/e/g' -e 's/Alfa/xxxxxx/g' file.txt
No -e option is needed, since you can concatenate multiple expressions with a ';' character:
sed -i 's/E/e/g;s/Alfa/xxxxxx/g' file.txt