#!/bin/bash # Script to list all files recursively using recursive bash function function listFileInDir { find $1 -maxdepth 1 -type f DirCount=$(find $1 -maxdepth 1 -mindepth 1 -type d | wc -l) # Recursive case if [ $DirCount -ge 1 ]; then find $1 -maxdepth 1 -mindepth 1 -type d | while read d; do echo Recursing into $d listFileInDir $d done fi } listFileInDir $1