Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Help with vi

Thread Tools
 
Search this Thread
 
Old 20 July 2006, 12:32 PM
  #1  
druddle
Scooby Regular
Thread Starter
 
druddle's Avatar
 
Join Date: Mar 2001
Location: Berkshire
Posts: 5,528
Likes: 0
Received 0 Likes on 0 Posts
Default Help with vi

Hello

I have a massive Solaris /etc/vfstab file that has a load of entries I need to copy but change a portion of the name in it, as i have created a duplicate Oracle Apps environment on my Netapp to do some testing on.

I am trying to work out how to do the following in vi, can anyone help me....

Replace all occurences of the string "tst" with "dba" from the current line to the end of the file.

Thanks in advance.

Dave
Old 20 July 2006, 12:42 PM
  #2  
boxst
Scooby Regular
 
boxst's Avatar
 
Join Date: Nov 1998
Posts: 11,905
Likes: 0
Received 0 Likes on 0 Posts
Default

Hello

Urrgg... vi ... I used to hate and love it. Hate it because it's a pain, and love it because it was sometimes the only thing I could use having telnet'ed to an alien machine.

Anyway, have a read: http://www.eng.hawaii.edu/Tutor/vi.html and specifically for your request here: http://www.cs.bgu.ac.il/~arik/unix98...1-unix101.html

Steve
Old 20 July 2006, 12:43 PM
  #3  
DrEvil
Scooby Regular
 
DrEvil's Avatar
 
Join Date: Oct 2000
Location: Surrey, UK
Posts: 8,384
Likes: 0
Received 0 Likes on 0 Posts
Default

:1,$s/tst/dba/g

this will replace all occurances of tst with dba, even if more than one entry per line (g = global per record).
Old 20 July 2006, 12:44 PM
  #4  
DrEvil
Scooby Regular
 
DrEvil's Avatar
 
Join Date: Oct 2000
Location: Surrey, UK
Posts: 8,384
Likes: 0
Received 0 Likes on 0 Posts
Default

Ps. you can substitute the '1' for the starting line number

PPS. you can find out the starting line number using

:# <return>
Old 20 July 2006, 12:47 PM
  #5  
druddle
Scooby Regular
Thread Starter
 
druddle's Avatar
 
Join Date: Mar 2001
Location: Berkshire
Posts: 5,528
Likes: 0
Received 0 Likes on 0 Posts
Default

Top one, thanks Steve/Alex.

Dave




All times are GMT +1. The time now is 12:35 AM.