Find all files ending with .jpg in the current directory and all subdirectories, then for each file found, run the command "md5sum" on it and append the output to the file ~/hashes.txt, then execute the commands.
find ~ -name '*.jpg' | sed 's/.*/md5sum & >> ~/hashes.txt/' | sh