Skip to content

Instantly share code, notes, and snippets.

@seamusabshere
Last active December 17, 2015 12:49
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 seamusabshere/5612213 to your computer and use it in GitHub Desktop.
Save seamusabshere/5612213 to your computer and use it in GitHub Desktop.
~/bin/gg and ~/bin/mmv
#!/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
#!/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