Find all files with the extension ".sh" in the current directory and its subdirectories, and then use xargs to run the sed command to remove any whitespace at the end of each line.
find ~ -iname '*.sh' | xargs sed -i 's/\s*$//'