-
-
Save seamusabshere/5612213 to your computer and use it in GitHub Desktop.
~/bin/gg and ~/bin/mmv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
read -p "Replace contents? (y/n) " RESP | |
if [ "$RESP" = "y" ]; then | |
ack --print0 -l "$1" | xargs -0 -n 1 gsed --in-place="" -e "s%$1%$2%g" | |
fi | |
read -p "Replace in filenames? (y/n) " RESP | |
if [ "$RESP" = "y" ]; then | |
find . -print0 -not -path "*.git*" -a -name "*$1*" | xargs -0 -n 1 mmv "s/$1/$2/" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# rename script examples from lwall: | |
# rename 's/\.orig$//' *.orig | |
# rename 'y/A-Z/a-z/ unless /^Make/' * | |
# rename '$_ .= ".bad"' *.f | |
# rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' * | |
$op = shift; | |
for (@ARGV) { | |
$was = $_; | |
eval $op; | |
die $@ if $@; | |
rename($was,$_) unless $was eq $_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment