I'm quite new to Linux and bash scripting, and I've hit a roadblock in a script I'm writing. At the moment I have it so that a user can enter a file path and the name of an editor, like pico, and it will automatically bring up their file for them to edit. I am trying to figure out how to add code to this so that the file will be copied before
any edits and saved as a separate file from the main file. I don't know how to copy the contents of a file, or a file before it's been edited, and I don't know how to write code to automatically generate a name for the previous versions of the file.
Below is the code that I have written so far:
echo "Please Enter a Text Editor: "
echo "Please Enter a Filepath: "
if [ -e $FILEPATH ]
echo "That is not a valid filepath or editor."
Basically, I am aiming to have a directory with the main version of a file, eg, Story.txt, alongside the previous versions of it, eg Story_a.txt, Story_b.txt, etc.
Any help would be greatly appreciated