TinyURL widget - shorten your URL's for free!

Enter a long URL to make tiny:

Saturday, September 5, 2015

Make Archve From Folder

I wrote a simple - too simple - and poorly written shell script to make an archive file out of a directory containing the name of the computer, the date including hours,  and the project name.

#!/bin/bash
# make archive folder DRE 2015
# Description: makes a named folder and archives it from a GNU Autotools
#specific CVS env vars
#export CVS_RSH=ssh
#export DIR=/usr/local/cvsroot
#export CVSROOT=:pserver:dave@dogma:$DIR

#clean out files if program
make distclean
# remove old copies of archives
rm -fr *.tar.gz

#create dated folder for new mods
storedate=$(date -Ihours)
project=$(printf '%q\n' "${PWD##*/}")
name=$(uname -n)

total="$storedate-$project-$name"
mkdir "$total"
cd "$total"
cp -r  ../* .
rm -fr "$total"
cd ..
tar -czf "$total.tar.gz" "$total"
It isn't the wisest script but people forget the point of unix.  It wasn't to be masters of all aspects of the operating system and tools, but to make the computer do the work so the human didn't have to. I did a quick search for the proper way to copy a folder without itself in the new folder.  I wasn't  happy with what I found so I just used basic commands I knew would work. I don't need to be expert to get it to work. That is a big stumbling block still with Unix. Usability. Knowing the perfect way to do something isn't important as most people assume.

This will waste the computers time executing extra commands.  But so what? It idles 90+% of the time when I am web browsing. It's not in a hurry. I am.

No comments:

Post a Comment