Newsgroups: alt.sources.d Path: utzoo!telly!problem!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: shell pipeline to reverse the order of lines. Message-ID: <1991Feb28.134628.14432@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario References: <2166@m1.cs.man.ac.uk> <1991Feb26.025903.5850@NCoast.ORG> <1991Feb27.010612.25618@agate.berkeley.edu> Date: Thu, 28 Feb 91 13:46:28 GMT In article <1991Feb27.010612.25618@agate.berkeley.edu> Paul Vojta writes: >In article <1991Feb26.025903.5850@NCoast.ORG> allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) writes: >>I don't understand what's wrong with >> nl | sort -nr | cut -f2- >What's wrong with > tail -r It isn't available on all systems. I once wrote a C program to do this. Here is the code slightly modified to remove some extra processing I needed for that application. Note that long lines could be handled using malloc/realloc but this worked for my purposes at the time and it was fast. It also didn't take more than 5 minutes to write, even with the extra stuff I needed at the time. /* flip.c */ #include void flip(void) { char entry[128]; if (gets(entry)) { flip(); printf("%s\n", entry); } } int main(void) { flip(); return(0); } -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government West Hill, Ontario, Canada | like no government! +1 416 281 6094 |