I am trying to recursively loop through a directory which contains numerous other directories and files and then find all the .rb files and copy them to another directory.
This is what I have so far but it is not working quite right as it copies everything in the current directory to the specified directory and does not only print .rb (ruby) files to the directory from the directory that is recursively iterated through.
This is the BASH command I am using:
ls -R metasploit-framework-master | grep .rb | cp * gems
In this command
metasploit-framework-master is the top-level directory to recursively iterate through with the
ls -R command. Also
gems is the directory to place all the .rb ruby files in.
The first part
ls -R metasploit-framework-master | grep .rb does seem to find all the ruby script source files but the last part
grep .rb | cp * gems does not seem to pipe in the output of the grep command to the copy command.
Can any BASH experts please help me out? `