have a folder structure as shown below ./all_files
-rwxrwxrwx reference_file.txt
drwxrwxrwx file1.txt
drwxrwxrwx file2.txt
drwxrwxrwx file3.txt
reference_file.txt has filenames as shown below
file1.txt
file2.txt
data in file1.txt and file2.txt are as shown below:
step_1 step_2 step_3
Now, I have to take particular step say step2 from each file
Note1: file name must present in reference_file.txt
Note2: step2 is not line no:2 always.
Note3: search should perform recursively.
I have used below scripts:
- which is not giving what i expected. All blank and unwanted lines displayed
#!/bin/sh
while read f; do
find . -type f -name "${f}" | xargs grep -l -F 'step_2'
done <reference_file.txt
- It is searching in only one folder but not searching recursively
#!/bin/sh
for i in reference_file.txt
do
find . -type f -name "${f}" | xargs grep -l -F 'step_2'
done
Please help me on this.