![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replacing a nul field with text | DarkHound | Shell Programming and Scripting | 3 | 09-04-2007 11:34 AM |
| Replacing text | chrchcol | Shell Programming and Scripting | 3 | 07-25-2006 09:30 AM |
| replacing text | ajaya | Shell Programming and Scripting | 2 | 04-12-2006 09:31 AM |
| Replacing text inside a directory | vatsan | UNIX for Advanced & Expert Users | 1 | 03-31-2006 11:34 PM |
| replacing text in an ascii doc | cubs0729 | Shell Programming and Scripting | 6 | 09-29-2005 12:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
At the : prompt type
Code:
#/opt/usr#/home/reddy/dump# |
|
#3
|
|||
|
|||
|
In vi:
:%s#\/opt\/usr#\/home\/reddy\/dump#g QED! (quite easily done!) |
|
#4
|
|||
|
|||
|
:%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
|
|||
|
|||
|
@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
|
|||
|
|||
|
Quote:
When '#' is used as delimiter no need to use '/' as '\/' but using '#' when the patten contains '/' adds more readability |
|
#7
|
|||
|
|||
|
better use perl search and replace.
Quote:
|
|||
| Google The UNIX and Linux Forums |