Up vote 1 down vote favorite 2 share g+ share fb share tw.
For example given the following input: pattern_a line1 line2 line3 pattern_b pattern_a line4 line5 line6 pattern_b I want line1 line2 and line3 to appear in one file and line4 line5 and line6 to appear in another file. I can't see a way of doing this without using a loop and maintaining some state between iterations of the loop where the state tells you where sed must start start search to looking for the start pattern (pattern_a) again. For example, in bash-like psuedocode: while not done if first ; then sed -n -e '/pattern_a/,/pattern_b/p' > $filename else sed -n -e '$linenumber,/pattern_b/p' > $filename fi linenumber = last_matched_line filename = new_filename Is there a nifty way of doing this using sed?
Or would awk be better? Bash sed awk link|improve this question asked Jun 8 '11 at 4:57sashang2,708511 100% accept rate.
How about this: awk '/pattern_a/{f=1;c+=1;next}/pattern_b/{f=0;next}f{print > "outfile_"c}' input_file This will create a outfile_x for every range.
Wow thanks you're the best – sashang Jun 8 '11 at 6:37 1 whitespace is free, don't be afraid of it – glenn jackman Jun 8 '11 at 10:59.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.