<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Simple Script Problem - reordering in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771129#M74692</link>
    <description>Hey procura,&lt;BR /&gt;&lt;BR /&gt;thanks for the hint towards File::ReadBackwards module from CPAN&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/doc/URI/File-ReadBackwards-0.97/ReadBackwards.pm" target="_blank"&gt;http://search.cpan.org/doc/URI/File-ReadBackwards-0.97/ReadBackwards.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Haven't stumbled yet over this one.&lt;BR /&gt;Of course this is *much* better than what I suggested as a quick one-liner.&lt;BR /&gt;&lt;BR /&gt;I will definitely install this one.&lt;BR /&gt;It's always worth to dig the CPAN first &lt;BR /&gt;&lt;BR /&gt;:-)</description>
    <pubDate>Thu, 25 Jul 2002 13:35:25 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2002-07-25T13:35:25Z</dc:date>
    <item>
      <title>Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771116#M74679</link>
      <description>Does anyone know how I can reorder a file, so the first line of the input file becomes the last line of the output file, and so on through out the input file...&lt;BR /&gt;&lt;BR /&gt;I don't want it sorted, just reversed...&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;Russ.</description>
      <pubDate>Wed, 24 Jul 2002 05:57:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771116#M74679</guid>
      <dc:creator>Russ Hancock_1</dc:creator>
      <dc:date>2002-07-24T05:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771117#M74680</link>
      <description>Hi,&lt;BR /&gt;If you know total number of lines of that file&lt;BR /&gt;you can do this for file of 900 lines.&lt;BR /&gt;#tail -n 900 myoriginalfile &amp;gt; invertedfile&lt;BR /&gt;&lt;BR /&gt;#man tail for more details.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;U.SivaKumar&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Jul 2002 06:05:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771117#M74680</guid>
      <dc:creator>U.SivaKumar_2</dc:creator>
      <dc:date>2002-07-24T06:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771118#M74681</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;nl -ba -s"~" file|sort -r|cut -f2-256 -d"~"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Use umlaut or something else for field definition see man&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                  steve Steel</description>
      <pubDate>Wed, 24 Jul 2002 06:07:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771118#M74681</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-07-24T06:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771119#M74682</link>
      <description>Hi Russ,&lt;BR /&gt;&lt;BR /&gt;this is yet another task for Perl ;-)&lt;BR /&gt;&lt;BR /&gt;But beware, this is a resource greedy solution as it requires the size of your file from memory stack, since we store the whole file in an array first.&lt;BR /&gt;So you shouldn't do this with really big files:&lt;BR /&gt;&lt;BR /&gt;perl -e '@tmp = reverse &amp;lt;&amp;gt;;print @tmp' /path/to/your/file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Unfortunately, if you have big files, something more elaborate is needed, which I imagine would require seek().&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Ralph</description>
      <pubDate>Wed, 24 Jul 2002 06:48:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771119#M74682</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2002-07-24T06:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771120#M74683</link>
      <description>Here's what I did in the end.&lt;BR /&gt;Thanks All.&lt;BR /&gt;&lt;BR /&gt;INPUT=$1&lt;BR /&gt;OUTPUT=$2&lt;BR /&gt;&lt;BR /&gt;rm -f $OUTPUT&lt;BR /&gt;&lt;BR /&gt;LINES=`wc -l $INPUT|awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;i=0&lt;BR /&gt;&lt;BR /&gt;while test i -lt $LINES&lt;BR /&gt;do&lt;BR /&gt;        i=`expr $i + 1`&lt;BR /&gt;        echo " $i \c"&lt;BR /&gt;        tail -n $i $INPUT | head -n 1 | tee -a $OUTPUT&lt;BR /&gt;done</description>
      <pubDate>Wed, 24 Jul 2002 07:01:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771120#M74683</guid>
      <dc:creator>Russ Hancock_1</dc:creator>
      <dc:date>2002-07-24T07:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771121#M74684</link>
      <description>Hi,&lt;BR /&gt;   you could try this rather simple solution:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;# reverse order of inputlines in $1&lt;BR /&gt;&lt;BR /&gt;PREVIOUS_FILE=/tmp/prev&lt;BR /&gt;if [ -w $PREVIOUS_FILE ]&lt;BR /&gt;then&lt;BR /&gt;        rm $PREVIOUS_FILE&lt;BR /&gt;fi&lt;BR /&gt;touch $PREVIOUS_FILE&lt;BR /&gt;&lt;BR /&gt;CURRENT_FILE=/tmp/curr&lt;BR /&gt;if [ -w $CURRENT_FILE ]&lt;BR /&gt;then&lt;BR /&gt;        rm $CURRENT_FILE&lt;BR /&gt;fi&lt;BR /&gt;touch $CURRENT_FILE&lt;BR /&gt;&lt;BR /&gt;cat $1| while read CURRENT&lt;BR /&gt;do&lt;BR /&gt;        echo $CURRENT &amp;gt; $CURRENT_FILE&lt;BR /&gt;        cat $PREVIOUS_FILE &amp;gt;&amp;gt; $CURRENT_FILE&lt;BR /&gt;        cat $CURRENT_FILE &amp;gt; $PREVIOUS_FILE&lt;BR /&gt;done&lt;BR /&gt;cat $CURRENT_FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 24 Jul 2002 07:07:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771121#M74684</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-07-24T07:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771122#M74685</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;try this&lt;BR /&gt;cat -n &lt;FILE name=""&gt; |sort -r|cut -f2 &amp;gt; &lt;OUT file=""&gt;&lt;BR /&gt;&lt;BR /&gt;regds&lt;BR /&gt;&lt;/OUT&gt;&lt;/FILE&gt;</description>
      <pubDate>Wed, 24 Jul 2002 07:29:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771122#M74685</guid>
      <dc:creator>V. V. Ravi Kumar_1</dc:creator>
      <dc:date>2002-07-24T07:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771123#M74686</link>
      <description>When using perl, you can use &lt;A href="http://search.cpan.org/search?dist=File-ReadBackwards" target="_blank"&gt;http://search.cpan.org/search?dist=File-ReadBackwards&lt;/A&gt; which is not that resource greedy</description>
      <pubDate>Wed, 24 Jul 2002 08:23:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771123#M74686</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-07-24T08:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771124#M74687</link>
      <description>Russ,&lt;BR /&gt;you could also try:&lt;BR /&gt;grep -n ^ input-file | sort -kr1n,1n | awk -F':' '{print $2}'&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Jul 2002 09:26:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771124#M74687</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2002-07-24T09:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771125#M74688</link>
      <description>#! /usr/bin/ksh&lt;BR /&gt;i=1&lt;BR /&gt;cat file.txt|while read xx&lt;BR /&gt;do&lt;BR /&gt;buf[$i]=`echo $xx`&lt;BR /&gt;i=$((i+1))&lt;BR /&gt;done&lt;BR /&gt;v=$((i-1))&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;if [ $v -ge 1 ];then&lt;BR /&gt;echo ${buf[$v]}&lt;BR /&gt;v=$((v-1))&lt;BR /&gt;else&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;AR</description>
      <pubDate>Wed, 24 Jul 2002 19:59:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771125#M74688</guid>
      <dc:creator>Aashish Raj</dc:creator>
      <dc:date>2002-07-24T19:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771126#M74689</link>
      <description>Hi Russ:&lt;BR /&gt;&lt;BR /&gt;Here's one way:&lt;BR /&gt;&lt;BR /&gt;# awk '{array [NR]=$0}; END{for (i=NR;i&amp;gt;0;i--) print array [i]}' inputfile &amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 24 Jul 2002 20:42:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771126#M74689</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-07-24T20:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771127#M74690</link>
      <description>HI&lt;BR /&gt;I would prefer the solution f U.Sivakumar&lt;BR /&gt;because it follows my most important approach : Keep it simple&lt;BR /&gt;&lt;BR /&gt;just use:&lt;BR /&gt; tail -10000000000 oldfile &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;it's a silly way just to use a very very big number for tail but IT WORKS and you get what you want.&lt;BR /&gt;As long as your file does not have that big amount of lines you will get the  file "oldfile" listed into "newfile" in reverse order.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Jul 2002 07:43:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771127#M74690</guid>
      <dc:creator>Reinhard Burger</dc:creator>
      <dc:date>2002-07-25T07:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771128#M74691</link>
      <description>Hi Russ,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;ed yourfile &amp;lt;&lt;EOD&gt;&lt;/EOD&gt;g/^/m0&lt;BR /&gt;w&lt;BR /&gt;EOD</description>
      <pubDate>Thu, 25 Jul 2002 12:36:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771128#M74691</guid>
      <dc:creator>Scott Williams_5</dc:creator>
      <dc:date>2002-07-25T12:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771129#M74692</link>
      <description>Hey procura,&lt;BR /&gt;&lt;BR /&gt;thanks for the hint towards File::ReadBackwards module from CPAN&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/doc/URI/File-ReadBackwards-0.97/ReadBackwards.pm" target="_blank"&gt;http://search.cpan.org/doc/URI/File-ReadBackwards-0.97/ReadBackwards.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Haven't stumbled yet over this one.&lt;BR /&gt;Of course this is *much* better than what I suggested as a quick one-liner.&lt;BR /&gt;&lt;BR /&gt;I will definitely install this one.&lt;BR /&gt;It's always worth to dig the CPAN first &lt;BR /&gt;&lt;BR /&gt;:-)</description>
      <pubDate>Thu, 25 Jul 2002 13:35:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771129#M74692</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2002-07-25T13:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771130#M74693</link>
      <description>For you two who said to use the tail command to do this, I have a suggestion for you.  Know what you are saying before giving answers on the forums!&lt;BR /&gt;&lt;BR /&gt;Tail DOES NOT reverse order display of files, simply takes the last "n" lines of the file to stdout.&lt;BR /&gt;&lt;BR /&gt;I.E. (yes I clipped the last two lines of cat)&lt;BR /&gt;cat /etc/hosts&lt;BR /&gt;127.0.0.1       localhost&lt;BR /&gt;10.37.161.12    sh0su012        tr0su010        loghost&lt;BR /&gt;&lt;BR /&gt;tail -2 /etc/hosts&lt;BR /&gt;127.0.0.1       localhost&lt;BR /&gt;10.37.161.12    sh0su012        tr0su010        loghost&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Doh, they are identical....&lt;BR /&gt;Look at the other suggestions for your answers and ignore the suggestions of using the tail command.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon</description>
      <pubDate>Thu, 25 Jul 2002 14:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771130#M74693</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2002-07-25T14:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771131#M74694</link>
      <description>Also "tail" does have a limitation on how many lines it can process.&lt;BR /&gt;&lt;BR /&gt;If you say tail -1000000, tail does a sequential read and has to keep the last 1000000 lines in memory. Sometime tail doesn't allocate enough memory, and I've seen where it just drops off the remaining lines.&lt;BR /&gt;&lt;BR /&gt;My 2 cents...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 25 Jul 2002 14:21:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771131#M74694</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-25T14:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771132#M74695</link>
      <description>Sadly the guy who said tail for this got 9 points and a magic answer....guess the user didnt test it, just had faith.. ;(</description>
      <pubDate>Thu, 25 Jul 2002 18:45:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771132#M74695</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2002-07-25T18:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771133#M74696</link>
      <description>Ok Guys&lt;BR /&gt;You got me !!!&lt;BR /&gt;Next time i'm hopefully a little bit mor carefull&lt;BR /&gt;:;-)</description>
      <pubDate>Fri, 26 Jul 2002 04:44:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771133#M74696</guid>
      <dc:creator>Reinhard Burger</dc:creator>
      <dc:date>2002-07-26T04:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771134#M74697</link>
      <description>Hi Guys,&lt;BR /&gt;Here are my 2 cens.&lt;BR /&gt;On Solaris, IBM-AIX and DIGITAL a mere &lt;BR /&gt;"tail -r /path/to/file/filename" &lt;BR /&gt;would do the job. On HP-UX "-r" option is not available.&lt;BR /&gt;&lt;BR /&gt;Rgds..&lt;BR /&gt;Suhas.&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Jul 2002 05:17:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771134#M74697</guid>
      <dc:creator>Suhas_2</dc:creator>
      <dc:date>2002-07-26T05:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Script Problem - reordering</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771135#M74698</link>
      <description>Hi Shanon,&lt;BR /&gt;I do agree that. I posted a theory that i have not tried  practically. I regret , If i have hurted you all.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;U.SivaKumar</description>
      <pubDate>Fri, 26 Jul 2002 05:38:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-script-problem-reordering/m-p/2771135#M74698</guid>
      <dc:creator>U.SivaKumar_2</dc:creator>
      <dc:date>2002-07-26T05:38:10Z</dc:date>
    </item>
  </channel>
</rss>

