One problem, I think it’s copying all the files inside folder /home/$USER whereas I just want the bash files which are in /home/$USER exlcluding all the subfolders. The command grep -rl ‘#!/bin/bash’ . | xargs -I {} cp {} /path/to/destination/ won’t exclude subfolders.