0

I have inputfile.txt with the following two lines:

"Falling back to scanning...\n"
"git commit"

I want bash to search a dir and its subfolder files for instances of the string, and then print the string and the instances to outputfile.txt. I have the following mybashfile.sh file:

#!/bin/bash  
while read p; do
    echo $p>>outputfile.txt
    grep -rFl "$p" ./Project/ >>outputfile.txt
    printf '%s\n'>>outputfile.txt
done <inputfile.txt

The problem is that echo $p echos "Falling back to scanning...n", removing the backslash and grep also only searches for "Falling back to scanning...n", so the grep result is empty despite the string being present in the Project directory files.

How to keep the \n so that the echo echos "Falling back to scanning...\n" and grep searches for it as well?

pmichaels
  • 143
  • 6

0 Answers0