I need help with a sed statement.
The problem: Insert a single line of text before the first instance of a
string in a file. The first character of the string is always the same,
the rest, variable. There may be several lines of this string in the
variable-length file. Example:
a
b
c
d
+something
+anything
- I want to insert the line "Insert" before the first line beginning with a
plus. To my understanding of sed it would be:
cat file | sed -e '/^+/ i\Insert\'
But that's not working. Note: I've been able to write the fix in awk,
but it's annoying me that I can't do it in sed.
Can anyone provide insight?
-- "War is an ugly thing, but not the ugliest of things; The decayed and ...........................................................................
...........................................................................
degraded state of m*and patriotic feelings which thinks that nothing
is worth war is much worse. A man who has nothing for which he is willing
to fight, nothing which is more important than his own personal safety,
is a miserable creature and has no chance of being free unless made and
kept so by the exertions of better men than himself"
- John Stuart Mill