Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing a text string in file 1

Status
Not open for further replies.

joeythelips

IS-IT--Management
Aug 1, 2001
305
IE
Hi,

I have a query which i imagine is pretty easy to do but i need the help of someone:

i have a script file whcih contains references to directories eg /u01/backup/ISCUST/ftpfiles.sh

I want to change the script using vi to /u01/backup/ROIMOP/ftpfiles.sh

How can i change the word ISCUST to ROIMOP in one go wherebver it appears in the scripts file?

Thanks in advance.

Joe
 
In vi, at a colon prompt:

g/ISCUST/s//ROIMOP/g

There is a simpler way I think, but I can't remember the exact method.
 
You were very close Ken :)

At the : prompt in Vi, type the following ...

1,$ s/ISCUST/ROIMOP/g

This basically tells Vi (through sed) to start a line 1 all the way through the end of the file and do a find and replace. The /g at the end is necessary, otherwise it will only change the first occurence that it finds.

Michael Christenson
Disaster Recovery Coordinator
Summit Information Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top