- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Replacing All Instances of a pathname with another...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 12:27 AM
тАО07-01-2005 12:27 AM
:1,$ s/
But I would get either a NO PRECEDING EXPRESSION or a TRAILING CHARACTERS error
How can I do a blanket or all instances replacement within vi editor? Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 12:31 AM
тАО07-01-2005 12:31 AM
Re: Replacing All Instances of a pathname with another in Vi Editor
1) Enclose your strings in single or double quotes.
2) Consider using sed to do the change, though you will still probably need to enclose your string in quotes.
Spaces are interpreted as separate statements by vi's change function or sed.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 12:36 AM
тАО07-01-2005 12:36 AM
SolutionWhat your issue probably is, is that you aren't escaping the /'s in your path, i.e.:
:%s/\/path\/to\/replace/\/with\/new\/path/g
(Note: in 'vim', :%s is equivalent to :%1,$s).
Whilst it looks ugly, it's simpley escaping the /'s so they aren't interpreted as regex seperators.
The neater way is to use a different pattern separator, i.e.:
:%s#/path/to/replace#/with/new/path#g
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 12:42 AM
тАО07-01-2005 12:42 AM
Re: Replacing All Instances of a pathname with another in Vi Editor
I tried the using the single quote approach and got an EXTRA CHARACTERS AT THE END OF THE SUBSTITUTE COMMAND error. Here is the syntax that I used:
:1,$ s/'/scratch5/stella/'/'/usr/bali/robert/'/g
I'm not familar with the sed command and don't know the syntax to use there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2005 12:50 AM
тАО07-01-2005 12:50 AM
Re: Replacing All Instances of a pathname with another in Vi Editor
I tried using the expressions that employed the # symbol, and that worked without problem. Thanks again for the help.