Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/307029547252084736
Source Link
dotancohen
  • 16.5k
  • 28
  • 87
  • 125

Backup file with .bak _before_ filename extension

I commonly backup config files on servers without version control like so:

# cp httpd.conf{,.bak} # ls httpd.conf httpd.conf.bak 

However, for files in the web root I take the time to carefully put the .bak before the filename extension so that the .php will remain and Apache will still send the file through the PHP interpreter if someone manages to guess or probe the server for such files:

$ cp index.php index.bak.php $ ls index.php index.bak.php 

Is there any way to use tab-completion and muscle memory to put the .bak before the filename extension? I have Tab{}←,.bak burned into muscle memory and I cannot use this nice "meat macro" on files in the web root.

Thanks.