#!/bin/bash find http -path */spedytor/*.sql | sort | uniq | cut -d/ -f 1-4 | uniq | while read LOCAL_DUMP_DIR do LOCAL_DUMP=$(find ${LOCAL_DUMP_DIR} -name *.sql -exec ls -t1 {} + | head -n1 | cut -d' ' -f 10) TARGET_DUMP=$(basename ${LOCAL_DUMP}) TARGET_DUMP=${TARGET_DUMP%%-*} cp "${LOCAL_DUMP}" dumps/sync/${TARGET_DUMP}.sql done