Seeking help with Sed statement.
l3gl3$$_m4r1n3_at_salmahayeksknockers.edu
Date: 05/15/05
- Next message: Paul Pluzhnikov: "Re: [SOLVED] Calling a Function in Shared Memory"
- Previous message: Måns Rullgård: "Re: recursive mutexes"
- Next in thread: Chris F.A. Johnson: "Re: Seeking help with Sed statement."
- Reply: Chris F.A. Johnson: "Re: Seeking help with Sed statement."
- Reply: Pascal Bourguignon: "Re: Seeking help with Sed statement."
- Maybe reply: Måns Rullgård: "Re: Seeking help with Sed statement."
- Reply: John Savage: "Re: Seeking help with Sed statement."
- Reply: John Savage: "Re: Seeking help with Sed statement."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 15 May 2005 19:30:51 GMT
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 moral 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
.............................................................................
dswan@m3m3t1ccand1ru.com http://www.memeticcandiru.com
- Next message: Paul Pluzhnikov: "Re: [SOLVED] Calling a Function in Shared Memory"
- Previous message: Måns Rullgård: "Re: recursive mutexes"
- Next in thread: Chris F.A. Johnson: "Re: Seeking help with Sed statement."
- Reply: Chris F.A. Johnson: "Re: Seeking help with Sed statement."
- Reply: Pascal Bourguignon: "Re: Seeking help with Sed statement."
- Maybe reply: Måns Rullgård: "Re: Seeking help with Sed statement."
- Reply: John Savage: "Re: Seeking help with Sed statement."
- Reply: John Savage: "Re: Seeking help with Sed statement."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|