quick backup of a file
KW Stannard

KW Stannard @kwstannard

About: Developer. Design pattern enthusiast. Tilting at Agile practices.

Joined:
Sep 9, 2019

quick backup of a file

Publish Date: Jan 21 '20
9 0

Recently I started trying to get competent at bash's string expansion phase and realized I could do the following to backup a file:

$ mv path/to/file.txt{,_}

Then to restore the file, swap the , and _ in the brackets.

$ mv path/to/file.txt{_,}

String expansion is a step that runs before executing the shell command so what is really being run can be viewed with the following:

$ echo mv path/to/file.txt{_,}
mv path/to/file.txt path/to/file.txt_
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment