The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-09-2005
yongho yongho is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 95
[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 (permalink)  
Old 06-09-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
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 (permalink)  
Old 06-09-2005
yongho yongho is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 95
oh

ahh, i see.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0