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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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 |
| ||||
| 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 > |