Click to See Complete Forum and Search --> : tar help


datadan
07-13-2001, 09:37 AM
In a perl script I use:
tar zcvf .../.../userhist/$user.tgz /.../$user

($user is a user input at runtime)
To move past users into a history file. I would love to suffix the system date onto the $user.tgz so it would look like $user_date_.tgz in case I get two users with same historical user ID.

Thanks,

EyesWideOpen
07-13-2001, 10:43 AM
my ($wday, $mon, $day, $time, $year) = split(/ /, localtime(time()));
my ($hour, $min, $sec) = split(/:/, $time);

$user = $user . "_" . $wday . $mon . $day . ".tgz";


For a user with a name of EWO this would give the variable user the value EWO_FriJul13.tgz. You could still run into a problem with duplicate filenames depending on how often the script is run so you may want to add the hours/min/sec to the filename as well.