Skip to content

Instantly share code, notes, and snippets.

@jktravis
Created June 2, 2013 03:43
Show Gist options
  • Save jktravis/5692564 to your computer and use it in GitHub Desktop.
Save jktravis/5692564 to your computer and use it in GitHub Desktop.
Bash rename with regex and back references.
for i in *.txt;
do
x=$(sed 's/^Foo\(Bar..*\)/\1/' <<< $i);
echo "$i renames to: $x";
mv $i $x;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment