<?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: shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874344#M704633</link>
    <description>thanx</description>
    <pubDate>Mon, 21 Feb 2005 07:18:07 GMT</pubDate>
    <dc:creator>Zee</dc:creator>
    <dc:date>2005-02-21T07:18:07Z</dc:date>
    <item>
      <title>shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874335#M704624</link>
      <description>cat $scriptpath/synclogs.log | while read LINE&lt;BR /&gt;   do&lt;BR /&gt;   case $LINE in&lt;BR /&gt;   .............&lt;BR /&gt;    &lt;CASE stmt=""&gt; &lt;BR /&gt;    ...........&lt;BR /&gt;......&lt;BR /&gt;&lt;BR /&gt;Quesiton:: is there anyway of finding out the line i m reading in $LINE variable is the last line in the file ?&lt;BR /&gt;&lt;BR /&gt;Any help? &lt;BR /&gt;&lt;/CASE&gt;</description>
      <pubDate>Tue, 07 Dec 2004 10:53:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874335#M704624</guid>
      <dc:creator>Zee</dc:creator>
      <dc:date>2004-12-07T10:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874336#M704625</link>
      <description>With something like that :&lt;BR /&gt;&lt;BR /&gt;lineCount=$(wc -l $scriptpath/synclogs.log)&lt;BR /&gt;lineNumber=0&lt;BR /&gt;cat $scriptpath/synclogs.log | while read LINE&lt;BR /&gt;do&lt;BR /&gt;lineNumber=$(($lineNumber+1))&lt;BR /&gt;if [ $lineNumber -eq $lineCount] ; then&lt;BR /&gt;  echo Last one&lt;BR /&gt;fi&lt;BR /&gt;case $LINE in&lt;BR /&gt;.............&lt;BR /&gt;&lt;CASE stmt=""&gt; &lt;BR /&gt;...........&lt;BR /&gt;......&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;/CASE&gt;</description>
      <pubDate>Tue, 07 Dec 2004 10:56:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874336#M704625</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-12-07T10:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874337#M704626</link>
      <description>You could set a variable to the line count at the begining of the script.&lt;BR /&gt; &lt;BR /&gt;nrec=`wc -l synclogs.log`&lt;BR /&gt; &lt;BR /&gt;Then count up each record.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 07 Dec 2004 10:57:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874337#M704626</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-12-07T10:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874338#M704627</link>
      <description>Hi Zee,&lt;BR /&gt;&lt;BR /&gt;I would do something like a &lt;BR /&gt;LIN=`cat file | wc -l `&lt;BR /&gt;NUM=0&lt;BR /&gt;cat file | while read LINE&lt;BR /&gt;do&lt;BR /&gt;let NUM="$NUM ++1"&lt;BR /&gt;case $LINE  in&lt;BR /&gt;...&lt;BR /&gt;if [ $NUM -eq $LIN ]&lt;BR /&gt;then&lt;BR /&gt;exit 0&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Dec 2004 11:00:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874338#M704627</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-12-07T11:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874339#M704628</link>
      <description>You could try something like:&lt;BR /&gt;&lt;BR /&gt;Before the cat statement do:&lt;BR /&gt;&lt;BR /&gt;LASTLINE=$(tail -1 $scriptpath/synclogs.log)&lt;BR /&gt;&lt;BR /&gt;Then in your 'while do' loop:&lt;BR /&gt;&lt;BR /&gt;if [[ "${LINE}" = "${LASTLINE}" ]] ; then&lt;BR /&gt;...do what you wanna do...&lt;BR /&gt;else&lt;BR /&gt;...do something else...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The above works on the assumption that each line is somehow unique, which could be a problem if it's a log file.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Dec 2004 11:02:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874339#M704628</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-12-07T11:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874340#M704629</link>
      <description>Thanks, is there any thing called EOF? can EOF be used for checking last line in the file ?</description>
      <pubDate>Tue, 07 Dec 2004 11:10:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874340#M704629</guid>
      <dc:creator>Zee</dc:creator>
      <dc:date>2004-12-07T11:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874341#M704630</link>
      <description>Since you are reading through "pipes", their is no way for the system to look ahead and see if the next line is EOF.&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 07 Dec 2004 11:13:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874341#M704630</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-12-07T11:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874342#M704631</link>
      <description>thanks Rodney,&lt;BR /&gt;&lt;BR /&gt;can u suggest any other way of reading line other than "pipe"  and then used EOF marker to check last line ? &lt;BR /&gt;&lt;BR /&gt;any suggestion ?</description>
      <pubDate>Tue, 07 Dec 2004 11:18:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874342#M704631</guid>
      <dc:creator>Zee</dc:creator>
      <dc:date>2004-12-07T11:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874343#M704632</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm curious. What problem are you trying to solve?  Using the while-read-do-done structure will read each line of the file, and the statements in your script immediately after the done line will be executed after the last line of the file is read, so you should be able to handle whatever you need to do after the end of file at that point.  &lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Dec 2004 11:22:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874343#M704632</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-12-07T11:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874344#M704633</link>
      <description>thanx</description>
      <pubDate>Mon, 21 Feb 2005 07:18:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4874344#M704633</guid>
      <dc:creator>Zee</dc:creator>
      <dc:date>2005-02-21T07:18:07Z</dc:date>
    </item>
  </channel>
</rss>

