I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash s
sed '0,/pattern/s/pattern/replacement/' filename
this worked for me.
example
sed '0,//s//Sub menu<\/Menu>/' try.txt > abc.txt
Editor's note: both work with GNU sed only.
sed