#!/usr/bin/env sh TO_DELETE=$( b2v4 ls b2://"$BUCKET_NAME" | tac | tail -n +8 | tr '\n' ' ' ) PIDS="" for file in $TO_DELETE; do b2v4 rm "b2://${BUCKET_NAME}/${file}" & PIDS="$PIDS $!" done for pid in $PIDS; do wait "${pid}" done