Find all files in the current directory (and its subdirectories) whose name ends with ".txt", and for each of them, execute the command "sed -i '' 's/sad/happy/g' {file_name}" (where {file_name} is the name of the file).
find ~ -iname ".txt" -exec sed -i '' 's/sad/happy/g' {} \;