#!/bin/sh where=/home/david to=/home/david/test for i in `find ${where} -maxdepth 1 -type f -exec echo "{}" \;`; do match=$( xxd -l 6 -s 0 -ps ${i} ) [ "${match}" = "6c73202d6c20" ] && echo "${i}" "${to}/" done