<?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: Help with an indexing shell script. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013388#M75565</link>
    <description>If python is the way to go, I am open to using that.&lt;BR /&gt;Especially if it would take you 5mins to solve my problem! ;)&lt;BR /&gt;The script is running on RedHat 7.2&lt;BR /&gt;I think python is bundled with it by default?&lt;BR /&gt;It would appear that it is from a quick file search...&lt;BR /&gt;I have to confess to knowing very little about python. Can I just call it from a shell script?&lt;BR /&gt;If so, it seems that could be the ideal solution....&lt;BR /&gt;&lt;BR /&gt;Luke</description>
    <pubDate>Wed, 02 Jul 2003 13:14:13 GMT</pubDate>
    <dc:creator>Luke Morgan</dc:creator>
    <dc:date>2003-07-02T13:14:13Z</dc:date>
    <item>
      <title>Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013384#M75561</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a shell script that takes a directory of item files, and cuts out two values from each. A year/week value and a quantity. It then matches the year/week value (eg 200322) against an index file, and replaces it.&lt;BR /&gt;&lt;BR /&gt;The index file contains year/week values in order and its second column contains an incremental value. Thus, after this script is run, each item file contains quantities with a number corresponding to its year/week.&lt;BR /&gt;After this, I have a perl script that pivots the item file into a row, with the indexed number indicating which column the quantity value is placed into.&lt;BR /&gt;&lt;BR /&gt;The problem is, this indexing script (attached) takes forever and a day to complete as it is performing a number of embedded loops.&lt;BR /&gt;Can anyone think of a more elegant and fast way of performing the same action?&lt;BR /&gt;&lt;BR /&gt;Thanks for your time&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Wed, 02 Jul 2003 12:02:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013384#M75561</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-02T12:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013385#M75562</link>
      <description>at a first look, it seems to me that the first two lines ('idxyearweek=...' and 'index=...') of the innermost loop (for x...) generate always the same results every time the loop is executed.&lt;BR /&gt;Maybe generating there results only 1 time and then re-read them could help. And even better could be keep them into memory (if they didn't need plenty of ram space). I don't know how to do this in shell, I'm not so expert about it.&lt;BR /&gt;Personally, I'll re-write this script in Perl or (my favorite) Python; it should be easy and surely run faster.&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;Claudio</description>
      <pubDate>Wed, 02 Jul 2003 12:36:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013385#M75562</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-02T12:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013386#M75563</link>
      <description>Thanks for that Claudio.&lt;BR /&gt;If you know how to re-write the script easily in perl, could you help me?&lt;BR /&gt;My perl skills are worse than terrible! :)&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Wed, 02 Jul 2003 12:45:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013386#M75563</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-02T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013387#M75564</link>
      <description>Since I started using Python (1 year ago) I immediately stopped using Perl, so my skills aren't so good now, too... (There's someone in this forum who hate me now :-)&lt;BR /&gt;&lt;BR /&gt;I think I could rewrite it in 5-10 mins with the snake, but going to dig in my Perl's memories could take me much more time. Maybe somebody out there could come and help us!&lt;BR /&gt;&lt;BR /&gt;Ciao&lt;BR /&gt;CC</description>
      <pubDate>Wed, 02 Jul 2003 13:08:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013387#M75564</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-02T13:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013388#M75565</link>
      <description>If python is the way to go, I am open to using that.&lt;BR /&gt;Especially if it would take you 5mins to solve my problem! ;)&lt;BR /&gt;The script is running on RedHat 7.2&lt;BR /&gt;I think python is bundled with it by default?&lt;BR /&gt;It would appear that it is from a quick file search...&lt;BR /&gt;I have to confess to knowing very little about python. Can I just call it from a shell script?&lt;BR /&gt;If so, it seems that could be the ideal solution....&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Wed, 02 Jul 2003 13:14:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013388#M75565</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-02T13:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013389#M75566</link>
      <description>I made the python script (it is attached).&lt;BR /&gt;you can run it as it was a shell script (look at the first like with the name of the interpreter; it must point to the path of your python executable. I'm using redhat 7.3, maybe /usr/bin/python2 is right).&lt;BR /&gt;&lt;BR /&gt;you can give it the execute permission just like any other script, chmod +x &lt;FILENAME&gt;. Even the .py extension isn't necessary.&lt;BR /&gt;Or you can run it with the interpreter directly:&lt;BR /&gt;$ python2 &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;It is a little bit longer that your shell script, 'cause shell is more file-manipulation oriented (but python is great when manipulating strings).&lt;BR /&gt;&lt;BR /&gt;Hope it works, I haven't tested it because i haven't your data.&lt;BR /&gt;&lt;BR /&gt;Tell me if it runs.&lt;BR /&gt;&lt;BR /&gt;Claudio&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 02 Jul 2003 13:43:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013389#M75566</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-02T13:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013390#M75567</link>
      <description>Thank you so much for that!&lt;BR /&gt;I named the script python.py and when I ran it, I got the following...&lt;BR /&gt;&lt;BR /&gt;# /usr/bin/python python.py&lt;BR /&gt;Traceback (innermost last):&lt;BR /&gt;  File "python.py", line 8, in ?&lt;BR /&gt;    f = file(datadir + 'arrayfile', 'r')&lt;BR /&gt;NameError: file&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jul 2003 14:02:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013390#M75567</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-02T14:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013391#M75568</link>
      <description>this error is caused by the old version of the interpreter, python 1.5. It is installed because RH7.2 needs it for its redhat-specific administrative tools.&lt;BR /&gt;&lt;BR /&gt;You can do two things:&lt;BR /&gt;&lt;BR /&gt;1. change the function name 'file' to 'open' (this is its name in python 1.5, but now it is deprecated),&lt;BR /&gt;2. use the python 2 interpreter. It should be installed:&lt;BR /&gt;&lt;BR /&gt;$ rpm -qa | grep python2&lt;BR /&gt;&lt;BR /&gt;should show a line like 'python2-xxx.xxx-xxx'&lt;BR /&gt;if it is, with the command&lt;BR /&gt;&lt;BR /&gt;$ which python2&lt;BR /&gt;&lt;BR /&gt;you can find the full path of the interpreter.&lt;BR /&gt;&lt;BR /&gt;Hi&lt;BR /&gt;Claudio</description>
      <pubDate>Wed, 02 Jul 2003 14:15:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013391#M75568</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-02T14:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013392#M75569</link>
      <description>Thank you Claudio,&lt;BR /&gt;your help has been superb!&lt;BR /&gt;The python script is excellent! Far quicker.&lt;BR /&gt;Only one small problem.&lt;BR /&gt;I can best illustrate by comparing the results from the original shell script, to the python result.&lt;BR /&gt;&lt;BR /&gt;Shell script:&lt;BR /&gt;116|106&lt;BR /&gt;124|96&lt;BR /&gt;125|101&lt;BR /&gt;127|2&lt;BR /&gt;130|50&lt;BR /&gt;&lt;BR /&gt;Python script:&lt;BR /&gt;116|106&lt;BR /&gt;124|96&lt;BR /&gt;125|101&lt;BR /&gt;127|2&lt;BR /&gt;130|50&lt;BR /&gt;116|106&lt;BR /&gt;&lt;BR /&gt;124|96&lt;BR /&gt;&lt;BR /&gt;125|101&lt;BR /&gt;&lt;BR /&gt;127|2&lt;BR /&gt;&lt;BR /&gt;130|50&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Wed, 02 Jul 2003 14:34:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013392#M75569</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-02T14:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013393#M75570</link>
      <description>I cannot figure out what's the difference. could you post here a little subset of your data (with the directory structure) and the right results? so I can run my script and do a comparison.&lt;BR /&gt;&lt;BR /&gt;Hi&lt;BR /&gt;Claudio</description>
      <pubDate>Thu, 03 Jul 2003 05:15:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013393#M75570</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-03T05:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013394#M75571</link>
      <description>you can put all in a .zip or .tar.gz.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 06:40:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013394#M75571</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-03T06:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013395#M75572</link>
      <description>Thanks again Claudio.&lt;BR /&gt;I have attached a small set of data as you asked.&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Thu, 03 Jul 2003 07:03:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013395#M75572</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-03T07:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013396#M75573</link>
      <description>I have re-run the script again this morning.&lt;BR /&gt;&lt;BR /&gt;I am sorry, I made a mistake.&lt;BR /&gt;The only issue with the results, is that &lt;BR /&gt;there is a blank line between each value set.&lt;BR /&gt;&lt;BR /&gt;I can write another script to remove the blanks but if the python could be altered slightly to remove them that would obviously be preferable.&lt;BR /&gt;Is that easy ?&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Thu, 03 Jul 2003 07:13:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013396#M75573</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-03T07:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013397#M75574</link>
      <description>I corrected the script. It's attached. &lt;BR /&gt;&lt;BR /&gt;This time should be good.&lt;BR /&gt;&lt;BR /&gt;Have fun,&lt;BR /&gt;Claudio&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 09:09:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013397#M75574</guid>
      <dc:creator>Claudio Cilloni</dc:creator>
      <dc:date>2003-07-03T09:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with an indexing shell script.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013398#M75575</link>
      <description>Excellent!&lt;BR /&gt;&lt;BR /&gt;Thank you very much for all your help.&lt;BR /&gt;You have saved me lots of time.&lt;BR /&gt;Much appreciated.&lt;BR /&gt;&lt;BR /&gt;Luke</description>
      <pubDate>Thu, 03 Jul 2003 09:13:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-an-indexing-shell-script/m-p/3013398#M75575</guid>
      <dc:creator>Luke Morgan</dc:creator>
      <dc:date>2003-07-03T09:13:58Z</dc:date>
    </item>
  </channel>
</rss>

