Restore .bak files

bash, linux, shell

Solution

for file in *.sh.bak dir/*.sh.bak; do cp "$file" "${file//.bak}"; done

Or you could use `mv` instead of `cp`.

Problem

I ran a perl script using ``` perl -p -i.bak -e "..." *.sh dir/*.sh ``` This created a copy of every file like ``` script.sh script.sh.bak ``` I now want to restore from the `.bak` files. How can I do this easily?

Original source

Related problems