The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-19-2008
on9west on9west is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 14
Replace text in multiple files

Dear all

My task is to replace a strings in multiple files.

filename: file1
Quote:
.....
receiverIP=abc.server.com
I can use sed to replace abc.server.com to unix.server.org
e.g. sed 's/abc.server.com/unix.server.org/g file1 > newfile1

I have 2 questions. How do I
  1. directly save file1 instead of append to newfile1. I know I can pipeline the "mv newfile1 file1" afterward. I just want to know if there is a simply solution.
  2. If I have 10 files need to replace strings, i.e. file1 file2 ....file10. Can I do it in a single command? I read some old post sed -i can do. However, my AIX machine not support -i argument. Below is part of my man page of sed.
sed Command
Purpose
Provides a stream editor.
Syntax
sed [ -n ] Script [ File ... ]
sed [ -n ] [ -e Script ] ... [ -f ScriptFile ] ... [ File ... ]

Thank you very much for your help in advanced.