4/2/2019 - 12:04 PM

find all files that contain a string and write to file

grep -R "my_string" *

grep -rln --include \*.R --include \*.Rmd "value" | while read -r line; do echo; echo $line; done > M:/files_to_check.txt

# -l just lists name.  
# -r or -R are recursive (looks in subdirectories)
# -n gives the line number in the file

# find files which contain "foo", and pipe those files to a grep looking for "bar" 
 grep -lrZ "foo" * | xargs -0 grep -lr "bar"