07-02-2009 12:06 PM
Did you try it in HP-UX?
Does it actually work differently than in Linux?
sed is kind of sed. I can't remember it acting differently in HP-UX and Linux. I'm not a heavy user but have exchanged sed scripts between the two without a second thought.
Owner of ISN Corporation
07-02-2009 01:23 PM
I thought that it worked on HP-UX, but that it was supposed to be dot relative (.+4). Could not get it to work...
Scratching my head I hopped into vi and used the colon escape ":g/Pattern/,.+4 d" and it worked just fine. Everybody is gone for the holiday, perhaps an answer will show up next week.
07-02-2009 02:02 PM
Well the GNU versions of many utilities are far more feature-rich than the HP-UX ones, so this doesn't surprise me in the least.
In fact, the GNU documentaion notes that the form:
...is a GNU extension that matches addr1 and the N lines following addr1.
We can emulate your 'sed' command by using a bit of Perl which in this case is easy enough to deduce:
# perl -ne 'm/Pattern/ and $i=1,next;next if $i && $j++<4;print' file
07-02-2009 02:18 PM
If you like, you can fetch a GNU 'sed' from the Porting Centre. Be sure to get the run-time dependencies for a binary; or the build-time dependencies if you are compiling your own.
Lastly, as a new member to the ITRC, welcome! When you are satisfied with the answers you have received, please read:
07-03-2009 09:20 AM
Assigning points is a way of saying "thank you" and marking the thread to indicate to future readers which answers helped you to resolve your problem. Points increase the value of our community.