I have got a C file in which I would like to add an include statement of my own.
There are already a few include statements and mine should come right after the last existing one (to be neat).
With grep I can get the lines containing the word 'include' and I guess I should feed the last line of the result to a sed command to append a line but I don't know exactly how to do this part. Any suggestions ?
The explanation is fairly simple. When sed comes across a line that starts with "#include" it fetches the next line. If the next line just fetched does not begin with "#include" sed inserts the #include "myHeader.h" line at that spot.