Bogiecom.com
  • About
  • Magento
  • Sitecore
  • WordPress

Category Archives: Sed

SED find and replace string, then revert backup.

Posted on November 14, 2013 by bc-admin

So testing a large change of adding a virtual include to all of the files in a website. Mainly for adding analytics tracking beneath the body tag for Google Tag Manager/Universal Analytics.

Making the change in all files with the .php extension

1
find ./ -type f -name "*.php" -exec sed -i.bak 's//\n<!-- #include virtual="includes/analytics-universal.php" -->/g' {} \;

I’m not happy with what came about, so now I want to revert the change

1
find ./ -name "*.bak" -exec sh -c 'mv -f $0 ${0%.bak}' {} \;

If you want to keep your changes, run this to get rid of the .bak files

1
find ./ -name "*.bak" -exec sh -c 'rm -f $0' {} \;

Posted in Linux, Sed, Shell Scripting | Leave a comment |

Virtual Host Info from the Shell

Posted on May 10, 2012 by bc-admin

Quick way to get all of the ServerName’s values from the Apache configuration? Especially useful if VirtualHosts have been split into multiple files:

1
cat *.conf | egrep "ServerName (.*)" | sed "s/ServerName\s\(.*\)/\1/"

Posted in Apache Configuration, Bash, Grep, Sed, Shell Scripting | Leave a comment |

Pages

  • About
  • Magento
  • Sitecore
  • WordPress

Archives

  • January 2017
  • December 2013
  • November 2013
  • February 2013
  • January 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • November 2011
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009

Categories

  • .NET
  • Air Force
  • Apache Configuration
  • Bash
  • C#
  • Comma-Delimited
  • Custom Field Validator
  • Date Format
  • Dump Files
  • Files
  • Grep
  • Grooveshark
  • HTML
  • Image Resizing
  • Imagick
  • Integration
  • jQuery
  • Konami Code
  • Linux
  • Magento
  • Magento Third Party CMS Integration
  • Mini Shuttle
  • Miva Merchant 5.5
  • MySQL
  • PHP
  • Powershell
  • Regular Expressions
  • Rename-Item
  • Sed
  • Shell Scripting
  • Sitecore
  • Strings
  • Uncategorized
  • Updating Product Attributes
  • Video Games
  • Wordpress
  • X-37
  • XML
  • YUI Konami Event

CyberChimps WordPress Themes

© 2008 - 2016 Bogiecom.com