Type the following command to set the execution permissions for the script.
chmod + x gd.sh
Run the script with this command:
./gd.sh
You can use the date command to create a timestamp. The display script will create a folder with a timestamp as its name. It will then copy the entire text file from the current directory into it. By running this script regularly, you can take a text file image. And then it is possible to build a series of directories with different text file versions.
Note, this is not a strong backup system.
Create a text file with the following content and save it as snapshot.sh.
#! / bin / bash
# obtaining the date and time
date_stamp = $ (date + "% F-% H-% M-% S")
# tạo một thư mục với tên
mkdir "$ date_stamp"
# sao chép tập tin từ thư mục hiện thời vào nó
cp * .txt "$ date_stamp"
# all done, report back and exit
echo "Text file copied to directory:" $ date_stamp
Type the following command to set execution permissions.
chmod + x snapshot.sh
Run the script with the following command:
./snapshot.sh
You will see the newly created folder named after the executable script date. Inside that folder is a copy of the text file.
I wish you all success!