rename --no-act 's/(.*)\.yaml$/$1.yaml.bak/' *.yamlRemove the --no-act to actually make the changes.
The next logical progression is to want to do this more than once, so adding a timestamp to the backup is desirable, but I couldn't think of a way to make rename do this (you can't put backticks in the regex for instance). So here's a workaround
find . -name *.yaml -exec mv {} {}.bak.`date +%Y-%m-%dT%H:%M:%S%z` \;
1 comment:
if you're in bash, using things like:
for f in *.yaml;do stuff with $f;done
can be quite handy for iterative processing
Post a Comment