I have multiple subdirectories at multiple levels containing a file results.out
./dir1/results.out ./dir2/dir21/results.out ./dir3/dir31/dir311/results.out
Now I need to search for
results.out and extract the directory path of those
results.out that contain the
string1, since I need to move these sub-directories to another location. For example, I can get the file path using the following code
for i in $(find . -type f -name "results.out); do grep -l "string1" $i done
How to modify the above code to get only the directory path?