1847818 Members
3590 Online
104021 Solutions
New Discussion

question on vi or ex

 
Ed Kwan_2
Advisor

question on vi or ex

How can I get vi to execute multiple commands at startup ?
Ex. vi +"2,5w newfile" oldfile

But I also want to quit after it writes the newfile.

My objective is to write out some portion of a file.

Thanks, Ed
2 REPLIES 2
harry d brown jr
Honored Contributor

Re: question on vi or ex

PIPE:

vi +"2,5w newfil|q" a

live free or die
harry
Live Free or Die
Ed Kwan_2
Advisor

Re: question on vi or ex

It works but I have to use

vi +"2,5w! newfile|q" a

otherwise, it gives me an error about newfile already exists even though it is not.

Thank for the help.