- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: VI Replacing Words
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
Forums
Discussions
Discussions
Discussions
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
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
10-12-2005 03:08 AM
10-12-2005 03:08 AM
Could anyone know how to replace numerous lines of words using vi as follows:
/disk3/test_bk --> /disk7/test_bk
have to use the whole words, as /disk3 has been used in other places.
I have tried :s/disk3/test_bk/disk7/test_bk, as there are more that one '/', it doesn't work.
Thanks.
Solved! Go to Solution.
- Tags:
- vi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:13 AM
10-12-2005 03:13 AM
Re: VI Replacing Words
=> protect slash with backslash.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:14 AM
10-12-2005 03:14 AM
Re: VI Replacing Words
:1,$s/\/disk3\/test_bk/\/disk7\/test_bk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:16 AM
10-12-2005 03:16 AM
Re: VI Replacing Words
:g$/disk3/test_bk$s$$/disk7/test_bk$g
That will do the entire file all at once...
Zero Points Please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:18 AM
10-12-2005 03:18 AM
Re: VI Replacing Words
:g?/disk3/test_bk?s??/disk7/test_bk?g
The first "g" does every line; the 2nd optional g at the end handles multiple replacements within the same line; if the 2nd is omitted only the first occurence within the line is replaced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:23 AM
10-12-2005 03:23 AM
Re: VI Replacing Words
1,$ will search for the pattern from line 1 through the last line
If you leave off the g at the end only the first occurence of the the pattern in the line will be changed.
\ character tells vi not to interpret the / character -- treat it as a normal character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:24 AM
10-12-2005 03:24 AM
Re: VI Replacing Words
A. Clay --> best one and working
Pat & Jean --> ending up with //disk7/test_bk
Alan: not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:31 AM
10-12-2005 03:31 AM
Re: VI Replacing Words
the s??, if omit one ?, is still working.
Thanks everybody.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 03:32 AM
10-12-2005 03:32 AM
Re: VI Replacing Words
Zero points please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 04:00 AM
10-12-2005 04:00 AM
Re: VI Replacing Words
e.g.
source file
/disk3/test_bk
/disk3/test1
/disk4/test_bk
/disk3/test_bk/
target file
/disk7/test_bk
/disk3/test1
/disk4/test_bk
/disk7/test_bk/
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 04:15 AM
10-12-2005 04:15 AM
Re: VI Replacing Words
http://sunsite.uakom.sk/sunworldonline/swol-10-1997/swol-10-unix101.html