Show me a POSIX shell script and the equivalent bash script that flatten a hierarchy of folders by copying all files to a another folder.