Unix Technical Forum

tac (reverse of cat) as pure executable for HP-UX 10.20

This is a discussion on tac (reverse of cat) as pure executable for HP-UX 10.20 within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Hi everybody, can anyone send me tac (reverse of cat) as pure executable for HP-UX 10.20 Could not find ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 06:43 AM
Paul Bullack
 
Posts: n/a
Default tac (reverse of cat) as pure executable for HP-UX 10.20

Hi everybody,

can anyone send me
tac (reverse of cat) as pure executable for HP-UX 10.20
Could not find it anywhere in the web.

Thanks in advance, Paul



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 06:45 AM
Ian Springer
 
Posts: n/a
Default Re: tac (reverse of cat) as pure executable for HP-UX 10.20

Paul Bullack wrote:
> Hi everybody,
>
> can anyone send me
> tac (reverse of cat) as pure executable for HP-UX 10.20
> Could not find it anywhere in the web.
>
> Thanks in advance, Paul
>


Hi,

I don't know where you can find a 10.20 tac binary. However, I dug up this
list of different ways to do a reverse cat that I compiled years ago.

-Ian

======

These are roughly arranged from most to least portable:

# These two methods are both POSIX.2 portable and work on large
# files, and are also faster than using awk or sed:
pr -tn | sort -nr | cut -f2-
nl -ba | sort -nr | cut -f2-

# I haven't actually tried this one yet...
ex -s '%g/^/m0|%p|q!' # to stdout
ex -s '%g/^/m0|w!|q!' # update original file

# Most implementations of awk can handle bigger files than sed.
# Note: On HP-UX 11, awk aborts if the input file contains any lines
# longer than 3000 characters. Method A below is considerably faster
# than method B:
awk '{l[NR]=$0} END{for (i=NR;i;i--) print l[i]}' # method A
awk '{x=$0"\n"x} END{ORS="";print x}' # method B

# Just be aware that most seds will choke on big files using the
# below methods (in older ones the limit can be as small as 4k,
# and even POSIX.2 requires only 8k). On HP-UX 11.00, sed
# dumps core on files >2k (or >4k w/ sed cumulative patch PHCO_22760
# installed). The same exact bug exists in Solaris 7. sed is also
# much slower than awk. Method A below is about 33% faster than
# method B or C:
sed -n 'x;1!H;${g;p;}' # method A
sed -n '1!G;h;$p' # method B
sed '1!G;h;$!d' # method C

# nl is part of XPG2-4, but not POSIX; works fine w/ large files, and it
# is very fast:
nl -ba -w9 | sort -nr | cut -f2-

# in HP-UX 10.00 and later, Perl 4 is included (/usr/contrib/bin/perl);
# Perl imposes no limit on the size of the input file, and it is extremely
# fast:
perl -e 'print reverse <>'

# tac is part of the GNU textutils package, which does not come w/ HP-UX,
# but should come with many versions of Linux & BSD, as well as Solaris 8
# or later; it is one of the least portable, yet the speediest, way to
# perform the task:
tac

# the -r (reverse) option for the tail command is not a standard POSIX
# option, yet Solaris, AIX, Tru64, IRIX, Open UNIX, and most BSD variants
# all support it
tail -r

--
Posted via a free Usenet account from http://www.teranews.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-17-2008, 06:45 AM
Paul Bullack
 
Posts: n/a
Default Re: tac (reverse of cat) as pure executable for HP-UX 10.20

Hello Ian,

Thanks a lot for these interesting proposals, I will use one of them
instead of "no tac".

Paul

"Ian Springer" <hpux.faq@gmail.com> schrieb im Newsbeitrag
news:4570fb68$0$20521$88260bb3@free.teranews.com.. .
> Paul Bullack wrote:
>> Hi everybody,
>>
>> can anyone send me
>> tac (reverse of cat) as pure executable for HP-UX 10.20
>> Could not find it anywhere in the web.
>>
>> Thanks in advance, Paul
>>

>
> Hi,
>
> I don't know where you can find a 10.20 tac binary. However, I dug up this
> list of different ways to do a reverse cat that I compiled years ago.
>
> -Ian
>
> ======
>
> These are roughly arranged from most to least portable:
>
> # These two methods are both POSIX.2 portable and work on large
> # files, and are also faster than using awk or sed:
> pr -tn | sort -nr | cut -f2-
> nl -ba | sort -nr | cut -f2-
>
> # I haven't actually tried this one yet...
> ex -s '%g/^/m0|%p|q!' # to stdout
> ex -s '%g/^/m0|w!|q!' # update original file
>
> # Most implementations of awk can handle bigger files than sed.
> # Note: On HP-UX 11, awk aborts if the input file contains any lines
> # longer than 3000 characters. Method A below is considerably faster
> # than method B:
> awk '{l[NR]=$0} END{for (i=NR;i;i--) print l[i]}' # method A
> awk '{x=$0"\n"x} END{ORS="";print x}' # method B
>
> # Just be aware that most seds will choke on big files using the
> # below methods (in older ones the limit can be as small as 4k,
> # and even POSIX.2 requires only 8k). On HP-UX 11.00, sed
> # dumps core on files >2k (or >4k w/ sed cumulative patch PHCO_22760
> # installed). The same exact bug exists in Solaris 7. sed is also
> # much slower than awk. Method A below is about 33% faster than
> # method B or C:
> sed -n 'x;1!H;${g;p;}' # method A
> sed -n '1!G;h;$p' # method B
> sed '1!G;h;$!d' # method C
>
> # nl is part of XPG2-4, but not POSIX; works fine w/ large files, and it
> # is very fast:
> nl -ba -w9 | sort -nr | cut -f2-
>
> # in HP-UX 10.00 and later, Perl 4 is included (/usr/contrib/bin/perl);
> # Perl imposes no limit on the size of the input file, and it is extremely
> # fast:
> perl -e 'print reverse <>'
>
> # tac is part of the GNU textutils package, which does not come w/ HP-UX,
> # but should come with many versions of Linux & BSD, as well as Solaris 8
> # or later; it is one of the least portable, yet the speediest, way to
> # perform the task:
> tac
>
> # the -r (reverse) option for the tail command is not a standard POSIX
> # option, yet Solaris, AIX, Tru64, IRIX, Open UNIX, and most BSD variants
> # all support it
> tail -r
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com