Solved

Changing code in multiple files that span several directories

Posted on 2006-07-05
2
232 Views
Last Modified: 2010-04-22
Hello All,

I have an APACHE web server running on Linux and I have to update some PHP code across several directories within the home directory.

All the files have the same name and are found in each subdirectory off of the home directory. Here are the names:

1. eventcalendar.php
2. eventcalendaradd.php
3. eventcalendaredit.php

All I need to do is replace the word "OTHER" in the below referenced code with "SC":

<?php if (empty($x_EventCode)) { $x_EventCode = "OTHER"; } // set default value ?><?php
$x_EventCodeList = "<select name=\"x_EventCode\"><option value=\"\">Please Select</option>";
$x_EventCodeList .= "<option value=\"" . htmlspecialchars("OTHER") . "\"";
if (@$x_EventCode == "OTHER") {
      $x_EventCodeList .= " selected";
}

I am pretty sure this can be done with SED or AWK, but I am not quite sure how. If anyone knows of a solution, I would appreciated it greatly.

Sincerely,

Bruce
0
Comment
Question by:safepointmedia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
slyong earned 500 total points
ID: 17046230
You can use a command like:

find ./ -type f -exec sed -i 's/OTHER/SC/' {} \;

but be a bit careful.. all OTHER will be replaced by SC.. this includes ANOTHER will become ANSC...
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 17046492
You can make slyong's script more robust:

find ./ -type f -exec sed -i 's/"OTHER"/"SC"/' {} \;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question