Relatively new to unix and still learning -- How do I search for files in a directory that contain a specific text and copy them to another directory ? I am using .ksh shell.
search for files with specific text and copy these files to another directory
files;search
You can simply do from the base directory you want to searchcp $(grep -r -l the pattern *) target_directorygrep -r means recusive -l means list the file path not the match in it.putting $() around the command will execute it and place the result in place in the outer command.cp will take a list of files, and as long as the last path is a directory copy them all in there.