ssh user@remote 'find . -maxdepth 2 -type f' | sort | sed "s@.*@ mkdir -p \"\`dirname '\0'\`\"; touch '\0' @" >test.txt vim test.txt sh <test.txt
ssh user@remote 'find . -maxdepth 1 -type f' | while read file; do touch "$file"; done