The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replacing a nul field with text DarkHound Shell Programming and Scripting 3 09-04-2007 03:34 PM
Replacing text chrchcol Shell Programming and Scripting 3 07-25-2006 01:30 PM
replacing text ajaya Shell Programming and Scripting 2 04-12-2006 01:31 PM
Replacing text inside a directory vatsan UNIX for Advanced & Expert Users 1 04-01-2006 03:34 AM
replacing text in an ascii doc cubs0729 Shell Programming and Scripting 6 09-29-2005 04:05 AM

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 01-25-2008
Chandu2u Chandu2u is offline
Registered User
  
 

Join Date: May 2007
Posts: 10
help required for replacing text in vi

Hi
Any one pls give me command in vi to replace /opt/usr with /home/reddy/dump .... i tried escaping / with \ bt its not working...


thanks in advance
  #2 (permalink)  
Old 01-25-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,930
At the : prompt type

Code:
#/opt/usr#/home/reddy/dump#
  #3 (permalink)  
Old 01-25-2008
dewets dewets is offline
Registered User
  
 

Join Date: Mar 2007
Location: Somerset West, South Africa
Posts: 10
In vi:

:%s#\/opt\/usr#\/home\/reddy\/dump#g


QED! (quite easily done!)
  #4 (permalink)  
Old 01-26-2008
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
:%s_/opt/usr_/home/reddy/dump_g

u can use anydelimiter ...since ur string cntains too many slashes, therefore to avoid escaping all the slashes and messy syntex... this 1 'll be the simplest.

Anchal.
  #5 (permalink)  
Old 01-26-2008
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
@dewets : why u again esacpe the slashes... if u alreadyusing delim as "#".
i dont think its needed...
is there any other reason..... correct me if i m wrong...
  #6 (permalink)  
Old 01-26-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,954
Quote:
Originally Posted by anchal_khare View Post
@dewets : why u again esacpe the slashes... if u alreadyusing delim as "#".
i dont think its needed...
is there any other reason..... correct me if i m wrong...
Yes, thats correct.

When '#' is used as delimiter no need to use '/' as '\/'

but using '#' when the patten contains '/' adds more readability
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 02:59 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