1752738 Members
5325 Online
108789 Solutions
New Discussion юеВ

vi editor

 
SOLVED
Go to solution
Francesco_13
Regular Advisor

vi editor

Hi,
i try to substitute disk01 with disk02 for all occurence in my file
command :% s/disk01/disk02/g

It's this command ok?

the vi return me:

unknow command character ' '

Thank!!
13 REPLIES 13
Steve Steel
Honored Contributor
Solution

Re: vi editor

Hi

Try

:1,$ s/disk01/disk02/g


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
G. Vrijhoeven
Honored Contributor

Re: vi editor

Hi,

There are several possibles. mine is:

:g/disk01/s//disk02/g

the g stands for global so multiple times on all lines.

HTH,

Gideon
Thierry Poels_1
Honored Contributor

Re: vi editor

hi,

the command is OK, but DON'T leave a blank between the "%" and the "s".

good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Sanjay Kumar Suri
Honored Contributor

Re: vi editor

: s/disk01/disk02/gc

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
MarkSyder
Honored Contributor

Re: vi editor

I think you've confused vi with sed.

I'm no sed expert, so I'm not sure of the syntax. I think this would be a long-winded change using vi. Have a look at the sed man page for the appropriate syntax.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Steve Steel
Honored Contributor

Re: vi editor

Hi


http://chris.tobkin.com/~tobkin/vi/


Is good


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
G. Vrijhoeven
Honored Contributor

Re: vi editor

Mark,

sed sollution:

cat file | sed 's/disk01/disk02/g'>>file2
mv file2 file

Regards,

Gideon
Sanjay Kumar Suri
Honored Contributor

Re: vi editor

Mistake in this

: s/disk01/disk02/gc

Instead use

:1,$ s/disk01/disk02/gc

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
MarkSyder
Honored Contributor

Re: vi editor

Thanks Gideon.

Sorry, I can't give you any points - it's not my thread!

Mark
The triumph of evil requires only that good men do nothing