You can tar and gzip all in one command, if you do use the -z argument. Since I was frustrated at having to constantly type:
Code:
tar -zpscf tarfilename directoryname
, I whipped up this little Perl utility which compresses an entire directory and names it after the directory, while appending the current date and time into the name:
Code:
#!/usr/bin/perl
$dir_in=shift(@ARGV);
chomp($dir_in);
print "Archiving $dir_in/* ...\n";
use POSIX qw(strftime);
$now_string = strftime "%m-%d-%Y_%H%M", localtime;
$tarname=$dir_in."_".$now_string.".tar.gz";
$execstring="tar -zpscf ".$tarname." ".$dir_in."/*";
#print($execstring); # for debugging...
exec($execstring);
print("\n");
I called this "rarch" for "recursive archiver", and placed it in /usr/local/bin. Now, let's say I have a directory called "htmlfiles", and I want to archive and compress the whole directory, and be able to tell at a glance exactly when I did this, I just go one level outside that directory and type "rarch htmlfiles" (without the trailing slash "/"

. This creates a gzipped tarfile called htmlfiles_07-23-2001_1027.tar.gz (Assuming current time is 7/23/2001 at 10:27 AM)
Obviously, since this does not also use Seconds in the time, if you call this utility twice in less than a minute on the same directory, you will overwrite the last file. If you really want seconds, or even microseconds it's no trouble to add it.