Timeline for Only cat from specific line X (with a pattern) to other specific line Y (with a pattern)
Current License: CC BY-SA 3.0
22 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 2, 2014 at 10:23 | comment | added | Stéphane Chazelas |
I'd say yes, the spec is not specific enough. I don't see what's the problem with c though. That seems unambiguous to me and I don't see how that's related to //. The ambiguity is about what // matches on when the previous match is part of a /x/,/y/ address range. There's also ambiguity in ls / | sed '/s/s/i/u/;s//<&>/g' for instance.
|
|
| Sep 2, 2014 at 9:51 | history | edited | mikeserv | CC BY-SA 3.0 |
added 2 characters in body
|
| Sep 2, 2014 at 9:44 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 6 characters in body
|
| Sep 2, 2014 at 9:35 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 6 characters in body
|
| Sep 2, 2014 at 9:26 | comment | added | mikeserv |
@StéphaneChazelas - so your point is that it is a bug in the spec for it not being specific enough? But what of the /ran/,/ge/c\\ behavior? They seem related... And besides, in my example - if it really were doing the range again - then shouldn't it !p the whole range? I didn't even see your answer till just now...
|
|
| Sep 2, 2014 at 9:23 | comment | added | Stéphane Chazelas |
Both make sense. // matches on the last pattern. For GNU sed, it'll be the last pattern match run, while on other seds, that'll be the last one lexically on the sed command script (even though it was not run. /goo/ is not run in /foo/,/goo/ if /foo/ matched). I would even say that the GNU sed behaviour is more inline with the POSIX spec.
|
|
| Sep 2, 2014 at 9:22 | history | edited | mikeserv | CC BY-SA 3.0 |
added 356 characters in body
|
| Sep 2, 2014 at 9:19 | comment | added | mikeserv |
@StéphaneChazelas - I think it's a GNU bug, maybe. I've been up and down their sed info pages and I've never noticed any reference to that behavior. Not doing so does seem a little out-of-character considering the explicit coverage of N and its last line behavior in the BUGS section. I suppose I should report it. Anyway, I updated the answer to reflect it.
|
|
| Sep 2, 2014 at 9:16 | history | edited | mikeserv | CC BY-SA 3.0 |
added 356 characters in body
|
| Sep 2, 2014 at 8:39 | comment | added | Stéphane Chazelas |
In the original one (tested on Unix V7) and probably all the derived commercial Unices (tested Solaris as well) as well as FreeBSD (and probably all the BSDs). ls / | sed -n '/dev/,/lib/!d;//!p;/lib/q' shows dev. Only exception I've found so far is GNU sed.
|
|
| Sep 2, 2014 at 6:57 | comment | added | mikeserv |
@StéphaneChazelas - which are those if you don't mind? That confuses me - specifically the note here about c[2addr]c\ text Delete the pattern space. With a 0 or 1 address or at the end of a 2-address range, place text on the output and start the next cycle. Maybe I should make that a question, huh? It's just that - GNU sed at, least - seems to do all of them. Or else, when used like I do above, only the specifically addressed lines. Is it a bug, do you think?
|
|
| Sep 2, 2014 at 6:24 | comment | added | Stéphane Chazelas |
sed -n '/foo/,/goo/!d;//!p;/goo/q' won't work with all sed implementations (//!p will only match on goo with some).
|
|
| Sep 2, 2014 at 3:42 | history | edited | HalosGhost | CC BY-SA 3.0 |
fix what appears to have been a mispaste
|
| Sep 2, 2014 at 3:38 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 65 characters in body
|
| Sep 2, 2014 at 3:30 | comment | added | HalosGhost |
Thank you! I removed the sed solution in my post considering that what I posted was not actually equivalent (in execution flow) to my awk solution. I'll leave my post to awk :)
|
|
| Sep 2, 2014 at 3:26 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 3 characters in body
|
| Sep 2, 2014 at 3:26 | comment | added | mikeserv | @HalosGhost - I edited it. Thanks for the inspiration - your own answer gets my vote. | |
| Sep 2, 2014 at 3:20 | history | edited | mikeserv | CC BY-SA 3.0 |
added 19 characters in body
|
| Sep 2, 2014 at 3:13 | history | edited | mikeserv | CC BY-SA 3.0 |
added 2 characters in body
|
| Sep 2, 2014 at 3:04 | comment | added | HalosGhost |
what's the advantage of that longer sed command over sed -n '/foo:/!{ /goo:/,/foo:/!p; }' bigFile? (Not being argumentative; generally curious.)
|
|
| Sep 2, 2014 at 3:02 | history | edited | mikeserv | CC BY-SA 3.0 |
added 274 characters in body
|
| Sep 2, 2014 at 2:29 | history | answered | mikeserv | CC BY-SA 3.0 |