1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-25 20:58:37 -06:00

chg: Switched make with switch-with-bk.sh

This commit is contained in:
Sayantan Santra 2024-03-17 03:11:50 -05:00
parent ac2d4072ec
commit 9de4d7ffe2
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F
2 changed files with 16 additions and 13 deletions

13
makebk
View file

@ -1,13 +0,0 @@
#!/bin/sh
# This simply makes backup of file(s) as filename.bak
if [ $# -ge 1 ]; then
for f in $@
do
[ -f "$f" ] && cp "$f"{,.bak}
done
else
echo "No filenames passed."
exit 1
fi

16
switch-with-bk.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# This simply switched the given file(s) with a $filename.bak file if it exists
# and creates a backup if it doesn't exist
if [ $# -ge 1 ]; then
for f in $@
do
[ -f "$f.bak" ] && mv "$f.bak" "$f.tmp"
[ -f "$f" ] && cp -l "$f"{,.bak}
[ -f "$f.tmp" ] && mv "$f.tmp" "$f"
done
else
echo "No filenames passed."
exit 1
fi