SaveVersion: Difference between revisions
Jump to navigation
Jump to search
Created page with "This script can be called from code editors olie Bluefish and Geany. It compares the current file with a saved version (<filename>_<timestamp>. If there is no saved v..." |
mNo edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This script can be called from code editors | [[Category:Programming]] | ||
[[Category:Linux/Unix]] | |||
This script can be called from code editors like [[Bluefish]] and [[Geany]]. | |||
It compares the current file with a saved version (<filename>_<timestamp>. If there is no saved version or if the save version differs from the current one a new copy is made. | It compares the current file with a saved version (<filename>_<timestamp>. If there is no saved version or if the save version differs from the current one a new copy is made. | ||
Latest revision as of 09:41, 20 January 2022
This script can be called from code editors like Bluefish and Geany.
It compares the current file with a saved version (<filename>_<timestamp>. If there is no saved version or if the save version differs from the current one a new copy is made.
#!/bin/bash
FILE=$1
echo Saving ${FILE}
if (( ! ls -1 "${FILE}"_* > /dev/null 2>&1 ) || ( ! diff "${FILE}" `ls -1 "${FILE}"_*|tail -1` > /dev/null 2>&1 ))
then
cp "${FILE}" "${FILE}_"`date +%Y%m%d_%H%M%S`
echo File saved as ${FILE}_"`date +%Y%m%d_%H%M%S`
fi