[vi]:%s / P/P/ ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [vi]:%s / P/P/ ?
# 1  
Old 06-09-2005
[vi]:%s / P/P/ ?

Could anyone tell me what the second line in this block of code in this here-document does.

vi /tmp/irfelogls2.txt <<!
:%s / P/P/
:wq!
!

1. Opens file.
2. Performs command ":%s / P/P/"
3. Write, and force-quit the editor.

Hm..

I think what it's doing is, searching for a regex of " P" and then replacing it with just a "P".. correct?

Edit: Ehh.. sorry... what a waste of a post, I think I answered my own question.
# 2  
Old 06-09-2005
Quote:
Originally Posted by yongho
Could anyone tell me what the second line in this block of code in this here-document does.

vi /tmp/irfelogls2.txt <<!
:%s / P/P/
:wq!
!

1. Opens file.
2. Performs command ":%s / P/P/"
3. Write, and force-quit the editor.

Hm..

I think what it's doing is, searching for a regex of " P" and then replacing it with just a "P".. correct?

Edit: Ehh.. sorry... what a waste of a post, I think I answered my own question.
ehhhh.... almost
it replaces the FIRST occurance ' P' with 'P' on every line of a file.
In order to replace ALL the occurances on all the lines:
:%s / P/P/g
# 3  
Old 06-09-2005
oh

ahh, i see.
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question