#!/bin/bash

echo '<<<scratch_permission>>>'

scratches=$(ls -l / 2> /dev/null | awk '{if ($9 ~ "^scratch.*") print $9}')

if [ ${#scratches} -eq 0 ]; then
  exit 0
fi

while read -r line; do
    if [ -d /$line ]; then
        echo "[$line]"
        waitmax 15 ls -la /$line/ 2> /dev/null | awk '{print $1" "$9}'
    fi
done <<< "$scratches"
