When I’m about to edit a configuration file or a bash script, sometimes I don’t know if the edit will work. In these cases I create a backup of it in numbered order (to keep track of them if I need to revert the changes). Because this is something I regularly do, I decided to build a script to make this easy. The usage is basic: define the file and destination-directory:
# bckfile definedfile.bash . ‘/home/johndoe/.local/bin/definedfile.bash’ -> ‘/home/johndoe/.local/bin/definedfile_00.bash’
Optionally a tag can be added too:
bckfile youdle .vault/ new ‘/home/johndoe/.local/bin/youdle’ -> ‘/home/johndoe/.local/bin/youdle_02-new’
A limitation of the script is that filename cannot have ‘periods’ in their filename. A heuristics of discovering multiple extensions and with . in the filename itself would be tough.