The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replace text in multiple files Tonka52 Shell Programming and Scripting 10 03-24-2008 08:11 AM
Find and replace files in multiple folders lodey Shell Programming and Scripting 6 09-28-2007 02:00 AM
How can I replace multiple lines from different files ranga27 Shell Programming and Scripting 2 02-07-2007 08:57 PM
Replace text in match files wilsonchan1000 UNIX for Dummies Questions & Answers 1 12-16-2002 09:21 AM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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.
  #2 (permalink)  
Old 05-20-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,910
use "ed" for direct replace inside the file...
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0