#!pkk

pawel koston

  • Blog
  • linux
  • Catalog
Subscribe

Replace all occurences of string in a directory (filenames too)

In order to replace FOO with BAR inside files within directory DIR

find /PATH/TO/DIR -type f -exec  sed -i 's/FOO/BAR/g' {} \;

Replace occurences in filenames:

find . -depth -name '*FOO*' -execdir bash -c 'for f; do mv -i "$f" "${f//FOO/BAR}"; done' bash {} +
Author pawelkoston
← Next Post   Previous Post →
  • #!pkk
  • EN
  • PL
  • projects
  • archive
  • RSS