Skip to content

Instantly share code, notes, and snippets.

@okalachev
Created October 27, 2012 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okalachev/3965760 to your computer and use it in GitHub Desktop.
Save okalachev/3965760 to your computer and use it in GitHub Desktop.
Script, that replaces a string in a directory (files/directories names & files content)
#!/bin/bash
# Script, that replaces a string in a directory (files/directories names & files content)
# Usage: hyper-replace what to
what=$1
to=$2
for file in `find * -depth`
do
mv $file `echo $file | sed -r "s/$what([^\/]*)$/$to\1/g"` 2> /dev/null
done
for file in `find * -type f`
do
cat $file | sed -r "s/$what/$to/g" > $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment