Posts

Showing posts from September, 2013

Mysql Fix Duplicate Entry | Mysql Master Slave

 mysql> show slave status\G Last_SQL_Error: Error 'Duplicate entry 'example@google.com' for key 'PRIMARY'' on query. STEP: Delete the entry on the slave (make sure you check if you need the data copy it! ) mysql> slave stop; mysql> SET GLOBAL sql_slave_skip_counter = 1; mysql> slave start; Insert the data on your master and it should replicate now on the slave.

Replace string on a folder recursively via grep and sed

This is the script I created to replace a string on folders recursively Many thanks to serverfault users and othe person that helped me create this script #!/bin/bash # user input echo "Enter string to be replaced" read OLDSTRING echo "Enter string to be placed" read NEWSTRING echo "===================================" echo "string to be replaced is $OLDSTRING" echo "string to be placed is $NEWSTRING  " echo "===================================" oldstr=$OLDSTRING #string to be replaced newstr=$NEWSTRING #new string to be placed echo "Enter folder path where we will find the string" read FOLDERPATH ### grep oldstring and output it in grep_output.txt    STEP1 grep -rl $oldstr $FOLDERPATH > grep_output.txt ### since there might be spaces or special characters on filenames, use sed to enclose them with quote and output in  sed_output.txt  STEP2 #for i in `cat grep_output.txt` #do sed -e "s/'/'\\\\'