#!/bin/bash grep -rl 'pdhcentral.com' . > recordsa_pdhcentral.txt for i in `cat recordsa_pdhcentral.txt`; do FileName=$i; FileBack=$FileName"_bk"; if [ -f $FileName ]; then sed 's/.*pdhcentral.*//g' $FileName > $FileBack; mv -f $FileBack $FileName else echo $FileName " Doesnt Exists...................!!!!! "; fi done