I have a number of files in a directory hierarchy. For each file, I'd like to add "abcdef" to the beginning, on its own line, and "ghijkl" to the end, on its own line. For example, if the files initially contained:
# one/foo.txt apples bananas # two/three/bar.txt coconuts
Then afterwards, I'd expect them to contain:
# one/foo.txt abcdef apples bananas ghijkl # two/three/bar.txt abcdef coconuts ghijkl
What's the best way to do this?
I've gotten as far as:
# put stuff at start of file find . -type f -print0 | xargs -0 sed -i 's/.../abcdef/g' # put stuff at end of file find . -type f -print0 | xargs -0 sed -i 's/.../ghijkl/g'
but I can't seem to figure out how what to put in the ellipses.