SED (linux) issue with recursive


I'm trying to replace the string $PHP_SELF by $_SERVER['PHP_SELF'] in all php files. I've ran this command, but it simply remove the string and replace by nothing:

cd /home/rg/public_html && find . -type f -print0 | xargs -0 perl -i.php -pe "s/\\\$PHP_SELF/\$_SERVER['PHP_SELF']/g"

Any ideas?


Just use gnu sed/grep/xargs, such as:

$ cd /home/rg/publick_html $ find . | grep "[.]php$" | xargs sed -e 's/\$PHP_SELF/\$_SERVER\['PHP_SELF'\]/g' -i


find . -type f -name "*.php" | xargs sed -e 's/\$PHP_SELF/\$_SERVER\['PHP_SELF'\]/g' -i

thanks @Utopik

good luck~


  • Apache/PHP is determined to serve the wrong file
  • Insert reportlab chart into django template
  • How do I dynamically insert a CSS class using PHP?
  • Format returning date format on Symfony2 FOSRestBundle
  • Custom component with dynamic configuration like jira, jdbc or azurestorage in talend
  • MySQL Full Text Search with utf8 (Persian/Arabic)
  • LINQ - Different results with LINQ to SQL vs LINQPad
  • Can't access index in folder when rewrite engine removes .php and .html
  • right format of php breadcrumb code
  • Swiftmailer email message returns error when attaching file
  • Wordpress header external php file - change title?
  • Modifying files nested in tar archive
  • Error Processing Request: Mage registry key “_singleton/inchoo_notes/feed_updates” already exists
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • what does prefix @- mean in makefile?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • npm 5.4.1 install/uninstall all failing
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • With Hadoop, can I create a tasktracker on a machine that isn't running a datanode?
  • Android full screen on only one activity?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Regex thinks I'm nesting, but I'm not
  • What is the “return” in scheme?
  • How do I fake an specific browser client when using Java's Net library?
  • Accessing IRQ description array within a module and displaying action names
  • Javascript Callbacks with Object constructor
  • How can I use Kendo UI with Razor?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Apache 2.4 - remove | delete | uninstall
  • AT Commands to Send SMS not working in Windows 8.1
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Linker errors when using intrinsic function via function pointer
  • How to disable jQuery.jplayer autoplay?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++