Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

hp ux version of sed command

SOLVED
Go to Solution
Occasional Visitor

hp ux version of sed command

wanted a similar sed command for hp ux
sed '/Pattern/,+4 d' - works fine in Linux.
7 REPLIES
Exalted Contributor [Founder]

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

Re: hp ux version of sed command

yes, I tried using with Linux and it works but not with HP-UX
Honored Contributor [Founder]

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 [Founder]

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 [Founder]

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

Re: hp ux version of sed command

Thanks Bob and James.. Appreciate your reply..
Acclaimed Contributor [Founder]

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