All pastes #549356 Raw Edit

Something

public text v1 · immutable
·published 2007-06-08 02:49 UTC
rendered paste body
WORK_DIR=/tmp/todisc-work
# what todisc symlinks are in /tmp
suffix=( /tmp/todisc-work[0-9]* )

# just get the numerical suffix
suffix=( ${suffix[@]##\/tmp\/todisc-work} )

# loop through and find the largest, and add 1 to it
for s in ${suffix[@]}; do
    ((s > new_suffix)) && new_suffix=$((s+1))
done

[[ -e /tmp/todisc-work ]] && WORK_DIR=/tmp/todisc-work${suffix}