a script to create a copy of a file as an archive named z_<NAME>.YYYY-mmdd
change the prepend as desired, or the date format... sorting is best by Year, month number and day
- The reason for this script is to preserve earlier versions of a script as a backup or for future script creation.
- Preserving solutions this way makes it easier to create new scripts quickly.
- Naming the file with a "z_" places it at the bottom of the directory listing.
- One of the reasons I created this was to rsync only the scripts in the main directory, will not use "-r" for this sync.
------------------------------------------------
--> cat z-archive-it
#!/bin/bash
# jm 13 dec 2018 - archive script - prepend with a "z_" - suffix with date © 2018
#######################
echo "creating an archive copy of $@ in the local directory, mv it where desired"
cp "$@" "z_$@.`date +%Y-%m%d`"
echo "#######################"
echo "copied $@ and named it: z_$@.`date +%Y-%m%d`"
echo "#######################"
ls -al
echo "#######################"
------------------------------------------------
luser@linux [/home/luser/bin]
------------------------------------------------
--> z-archive-it z-archive-it
creating an archive copy of z-archive-it in the local directory, mv it where desired
#######################
copied z-archive-it and named it: z_z-archive-it.2018-1213
#######################
total 52
drwxrwxr-x 6 luser luser 4096 Dec 13 23:40 .
drwxr-xr-x 19 luser luser 4096 Dec 13 22:30 ..
-rw-r--r-- 1 luser luser 228 Dec 13 23:34 list-hosts
drwxr-xr-x 3 luser luser 4096 Dec 13 23:37 NOTES
drwxr-xr-x 2 luser luser 4096 Dec 13 09:34 ssh-13dec2018
-rwxr-xr-x 1 luser luser 1542 Dec 13 22:12 undo-systemd-resolved.sh
-rwxr-xr-x 1 luser luser 378 Dec 13 23:39 z-archive-it
-rwxr-xr-x 1 luser luser 189 Dec 13 23:35 z_archive-script.2018-1213
-rw-r--r-- 1 luser luser 228 Dec 13 23:34 z_list-hosts.2018-1213
-rwxr-xr-x 1 luser luser 1542 Dec 13 23:37 z_undo-systemd-resolved.sh.2018-1213
-rwxr-xr-x 1 luser luser 378 Dec 13 23:40 z_z-archive-it.2018-1213
#######################
------------------------------------------------
JohnMeister.com
Today's Date:
|