I wrote a small script that find a line containing specific string I provide to the bash and write them to a text file.
grep -A $2 "$1" outFile.txt >> "$1-results.txt"
Now I want the search to be applied to 1000 file but the results will be in one text file.
The second thing I want is before starting the search of every file to write add a heading ' FILE 1 ' and when when File 1 finishes I add 'FILE 2' etc.
I have found answers but they did not work with me in a file , the worked on the terminal only. I tried to make some modification but I faild.
Update:
Directory has the following files:
res1.txt ........ res1000.txt
Input as an example:
Jhon Age
Which mean get any person with the name jhon and bring his age with the name.
Expected out put :
FILE1
Jhon 43
Jhon 55
FILE2
Jhon 66
.
.
.
.
.
FILE3
.
.
.
etc..