#!/bin/bash -e # Creates a new directory for mod-xslt release, # based on the current date and time # Check supplied arguments test -n "$dir_repository" || { echo "missing dir_repository" 2>&1 exit 1 } test -d "$dir_repository" || mkdir -p "$dir_repository" # Calculate ID while :; do date=`date +%Y%m%d` lastid=`(ls -d "$dir_repository/$date"* 2>/dev/null || true )|sed -e "s@${dir_repository}/@@"|sort -r |head -n1` if test -z "$lastid"; then lastid="${dir_repository}/${date}00" mkdir $lastid && break 2 || true else oldid="${dir_repository}/${lastid}" lastid="${dir_repository}/`expr \"$lastid\" + 1`" mkdir $lastid && break 2 || true fi done library_repository="$lastid"