Core Coding®

Linux Search & Replace

  Linux Search & Replace
A recursive search and replace linux command, for those massive file changes you don't feel like doing by hand.
#
# this method doesn't create any backup files

find ./* -type f -exec sed -i 's/oldtext/newtext/g' {} \;

#
# or
#
# this method creates backup files

find . -type f | xargs perl -pi~ -e 's/oldtext/newtext/g;'

#

Go back to resources
Home Mail GitHub