Skip to main content
18 events
when toggle format what by license comment
Jun 11, 2015 at 9:00 vote accept JoVe
Jun 11, 2015 at 8:52 vote accept JoVe
Jun 11, 2015 at 9:00
Jun 10, 2015 at 16:40 comment added terdon @JoVe OK, so, presumably, your <np> is actually "lines that don't begin with a 2" (that's what you're matching, anyway). Could you please accept one of the answers by clicking on the check mark to the left? That will mark the question as answered and is the way thanks are expressed on the Stack Exchange sites.
Jun 10, 2015 at 16:33 comment added JoVe @mikeserv Yes I understand. I'll do better next time. ;) I've get round the problem of <np> by doing this: '/\*\*/ {parse=1; next} /^[^2]/ {parse=0} parse==1 {print}' file. Thanks again !
Jun 10, 2015 at 16:26 comment added mikeserv @JoVe - your question isn't stupid - those are the good questions - it's misleading. I told you before, you're asking the wrong one - you can't be helped if you ask a question which does not apply to you. And if the data that you ask others to help you edit, is not actually your data then everyone has wasted their time. Do you see what I mean? That's why I said you need to start with asking - What the hell is <np>? - just like terdon just did.
Jun 10, 2015 at 16:04 comment added JoVe @mikeserv I'm a beginner in all this, so instead of reacting like that, tell me what is stupid in my question so I can learn. In my beginner's head, \*{4,} not working can happen because of 2 things: either it does not recognize * (so I tested it to be sure it recognizes it) or {4,} is not working and I find it strange. How is that stupid ?? Anyway it's not important. To Terdon: Well it's not a <, n, p and >, it is supposed to represent something else but I dont know what. Again, it's not important. Sorry to have wasted your time and thank you for your help !
Jun 10, 2015 at 15:48 comment added terdon @JoVe huh? What is <np>? Is that an actual <, n, p and > or is it supposed to represent something else? There's nothing special about it. It's possible that your awk flavor/version doesn't support {N,} but I can't know since you haven't told us anything about it. What OS are you on?
Jun 10, 2015 at 15:45 comment added mikeserv By the way - the tail|head thing doesn't work for anything but the first paragraph - it still prints ***\n.*\n<np> for all but the first paragraph.
Jun 10, 2015 at 15:30 comment added JoVe Thanks for the edited answer, but there are still a few problems left. awk '/\*{4,}/,/<np>/' file is not working but awk '/\*\*\*\*/,/<np>/' file works, why ? <np> seems to be a special character, it is not recognized by awk. But I can parse until "Predicted orbit" and remove the last 3 lines.
Jun 10, 2015 at 14:57 history edited terdon CC BY-SA 3.0
added 818 characters in body
Jun 10, 2015 at 14:07 comment added mikeserv It's mostly a hunch, actually, but this is all I know about it. I dunno if awk does anything with * as it does for \t, really. But according to that ENVIRON is one of only two ways to hand it string literals.
Jun 10, 2015 at 14:01 comment added terdon @mikeserv why? To avoid the quoting issues?
Jun 10, 2015 at 13:40 comment added terdon @JoVe please use the formatting tools to format your post. Just paste it directly into your question, select it and then hit the {} button.
Jun 10, 2015 at 13:37 comment added JoVe I edited my post : I put an extract of the file and an example of the awk command I used.
Jun 10, 2015 at 13:21 comment added terdon @JoVe the -v lets you set a variable. For example awk -v g="foo" 'BEGIN{print g} will return foo since that's the value of the variable g. I just wrote it with no space and used it to set the RS variable. What ******? I don't see that in your example. If you show us the actual file you are trying to parse (including this problematic ******), I can update my answer.
Jun 10, 2015 at 13:18 comment added JoVe The way I was doing it, I treated the entire file as one record (hence the RS=""), and I used FS to read the paragraph I want (read as a field by awk). It worked until I had to deal with a "******" separator. Do you know why ? Even when I double escape the * it's not working. Your solution looks quicker though : can you explain how is it working ? I am not familiar with the -vRS option.
Jun 10, 2015 at 12:06 comment added terdon @mikeserv because the title states "paragraph separated by ***" and because the output only shows the first set of lines. Since the OP refers to it as "the paragraph after ***", I assumed that the *** was between each paragraph. If that's not the case, the OP can use fredtantini's very good answer.
Jun 10, 2015 at 10:04 history answered terdon CC BY-SA 3.0