#!/bin/bash
sed -e 's/^foo/bar/' -e '1i foo foo foo' -e 's/foo$/baz/' <<< "foo bar baz"