Foreach file in a directory loop for file in $( find /path/to/dir -maxdepth 1 -type f -name "*.mp4" | sort ); do echo "$file" done Find duplicate files in a directory find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD