Computing.Net > Forums > Unix > unix script - find and replace

unix script - find and replace

Reply to Message Icon

Original Message
Name: amir
Date: December 3, 2003 at 23:08:43 Pacific
Subject: unix script - find and replace
OS: UNIX - Solaris
CPU/Ram: Sun, ultra10
Comment:

Hi all,

I have a lot of similar files that i have to update.
I need an unix script that scan all these file, looking for old templet and replace it with new one.

for example:
I have two similar files, file#1 .ex and file#2.ex
i need a scrip that scan these two flies and will replace 0101 templet with 1010 11 templet.

Old files:

file#1 .ex
0000
0101
1001

file#2 .ex
0000
0101
1111

New files:

file#1 .ex
0000
1010 11
1001

file#2 .ex
0000
1010 11
1111

Tanks,
Amir


Report Offensive Message For Removal

Response Number 1
Name: David Perry
Date: December 4, 2003 at 05:49:35 Pacific
Subject: unix script - find and replace
Reply: (edit)

Have you tried sed?

sed -e 's/0101/1010 11/' oldfile > newfile


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: unix script - find and replace

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software