Solved

Changing code in multiple files that span several directories

Posted on 2006-07-05
2
233 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 35

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

624 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