ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
sed doesn't pass the newlines - you get to see the "stripped" (chomp'd in perl parlance) line.
awk or perl might be a better bet.
Sorry, I'm not following. N pulls in the next line, so the buffer always has 2 lines it in with the \n in it. Many references talk about using this method to read in 2 lines with the \n embeded (not stripped).
My question is, why is this working for ONE of the conditions met in the file and not the others. The middle one even, not even the first or last. Very strange.
Yeah I had deleted that, but you'd already started replying apparently ... sorry.
Thinking about it some more, I think you're failing because you appear to be expecting each buffer will have every line followed by the next. What you actually get is every second line plus the next.
i.e. first data you get to work on is "line1\nline2", then you get "line3\nline4" ... (note you don't get "line2\nline3")
Add some dummy lines to your input, and you'll see what I mean - even using addressing won't get around this. Seems my suggestion of awk or perl still stands - but for a (hopefully) valid reason this time.
show in more details how your input file looks like, how you want your final output to be like. you do not need complex regular expressions to do what you want.
show in more details how your input file looks like, how you want your final output to be like. you do not need complex regular expressions to do what you want.
I'm actually wrapping all the subheading blocks in <UL> and </UL>, but I already have the <UL> part working and trying to use the most simple example here, but will mention that here for the sake of context of this exercise.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.