Insert text before a line into multiple files

The stream editor sed inserts text before a specified pattern.

sed -i '/pattern/i\inserted text' *.txt

The -i flag enables editing in place.

Photo by Clayton Cardinalli on Unsplash