hp ux version of sed command (274 Views)
Reply
Occasional Visitor
Hemang75
Posts: 3
Registered: ‎07-02-2009
Message 1 of 8 (274 Views)
Accepted Solution

hp ux version of sed command

wanted a similar sed command for hp ux
sed '/Pattern/,+4 d' - works fine in Linux.
Exalted Contributor
Steven E. Protter
Posts: 33,806
Registered: ‎08-15-2002
Message 2 of 8 (274 Views)

Re: hp ux version of sed command

Shalom,

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.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Occasional Visitor
Hemang75
Posts: 3
Registered: ‎07-02-2009
Message 3 of 8 (274 Views)

Re: hp ux version of sed command

yes, I tried using with Linux and it works but not with HP-UX
Honored Contributor
Bob E Campbell
Posts: 764
Registered: ‎03-31-2004
Message 4 of 8 (274 Views)

Re: hp ux version of sed command

Fun with regular expressions.

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.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 5 of 8 (274 Views)

Re: hp ux version of sed command

Hi:

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:

addr1,+N

...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

Regards!

...JRF...
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 6 of 8 (274 Views)

Re: hp ux version of sed command

Hi (again):

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.

http://hpux.connect.org.uk/hppd/hpux/Gnu/sed-4.2.1/

Lastly, as a new member to the ITRC, welcome! When you are satisfied with the answers you have received, please read:

http://forums.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...
Occasional Visitor
Hemang75
Posts: 3
Registered: ‎07-02-2009
Message 7 of 8 (274 Views)

Re: hp ux version of sed command

Thanks Bob and James.. Appreciate your reply..
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 8 of 8 (274 Views)

Re: hp ux version of sed command

Hi:

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.

http://forums.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.