branch4 Blog

Internet development with every single possibility.

[1 Liner] Easily Replacing a Domain in Multiple Files

| Comments

Just 1 liner I sometimes use.

    for i in `find -type f`;
    do
    grep "xxxxx.yyyyy.jp:1080" >& /dev/null $i;
    if [ $? -eq 0 ]; then
      sed -i.bak -e s,http://xxxxx.yyyyy.jp:1080,https://aaa.bbb.com, $i;
    fi
    done 
This will…

  1. find files that contains “xxxxx.yyyyy.jp:1080”
  2. replace http://xxxxx.yyyyy.jp:1080 => https://aaa.bbb.com

Comments