Bash script to replace a string within a file

# command line arguments are 1 search string and 2 the replacement
# handy for replacing ip addresses in host files
# example
for f in *
  echo "sed -i 's/$1/$2/g' $f" #let us know what we are about to screw up
  sed -i "s/$1/$2/g $f" #making it happen

Leave a Reply

Your email address will not be published. Required fields are marked *