'how can i turn a text file of results into a cleaned up version text file using a shell script [duplicate]

Does anyone know how could i to write a shell script that reads in a text file (i.e.tests.txt) as an input and then process it and saves the results on another file (i.e.cleantabletests.txt)

for example:

input tests.txt contains the following:

your test with name="firstTest" has finished succesfully but results="failed"
your test with name="secondTest" has finished successfully but results="passed"
your test with name="thirdTest" has finished successfully but results="passed"

process: use a shell script to read the tests.txt and process it to output the results in this cleantabletests.txt

output after tests.txt was processed cleantabletests.txt should look like this:

1, name="firstTest", results="failed"
2, name="secondTest", results="passed"
3, name="thirdTest", results="passed"

i am only interested in the names and results to use them to create a table afterwards



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source