<?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: LS Script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165078#M160185</link>
    <description>Actually, that's only the ls display part and doesn't account for file display - sorry.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
    <pubDate>Thu, 15 Jan 2004 07:10:16 GMT</pubDate>
    <dc:creator>Pete Randall</dc:creator>
    <dc:date>2004-01-15T07:10:16Z</dc:date>
    <item>
      <title>LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165074#M160181</link>
      <description>Hi Masters,&lt;BR /&gt;    Kindly help to write a script to get the file list with sequence no. If total no. of files to be selected is more than 10 then it should ask me two option whether to go next or  want to select the file which was displayed using sequence no.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ls *A*  --&amp;gt; total no of such files are 25&lt;BR /&gt;files should be displayed as below,&lt;BR /&gt;1. A1&lt;BR /&gt;2. A2&lt;BR /&gt;....&lt;BR /&gt;10. A10&lt;BR /&gt;Hit Enter for Next Page OR Select file no to display File&lt;BR /&gt;&lt;BR /&gt;So if i press enter it should display next page and if i press file no it should display that filename.&lt;BR /&gt;&lt;BR /&gt;I hope you understand my requirement.&lt;BR /&gt;Points will be given to all answers.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jan 2004 06:28:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165074#M160181</guid>
      <dc:creator>Ashwin_4</dc:creator>
      <dc:date>2004-01-15T06:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165075#M160182</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;export COUNT=0&lt;BR /&gt;for i in `ls`&lt;BR /&gt;do&lt;BR /&gt;let COUNT="COUNT++1"&lt;BR /&gt;echo "$COUNT $i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;&lt;BR /&gt;Gideon</description>
      <pubDate>Thu, 15 Jan 2004 06:41:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165075#M160182</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2004-01-15T06:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165076#M160183</link>
      <description>To number the files, you can use the nl command.&lt;BR /&gt;But you need to have it interactively. So it will become something like this:&lt;BR /&gt;&lt;BR /&gt;cnt=1&lt;BR /&gt;ls *A* | while read file&lt;BR /&gt;do&lt;BR /&gt;   filelist[$cnt]=$file&lt;BR /&gt;   (( cnt = $cnt + 2 ))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;page=1&lt;BR /&gt;&lt;BR /&gt;while [ true ]&lt;BR /&gt;do&lt;BR /&gt;(( idx = ( $page - 1 )* 10 + 1 ))&lt;BR /&gt;while [ $idx -le (( $page * 10)) -a $idx -lt $cnt ]&lt;BR /&gt;do&lt;BR /&gt;   printf "%4d %s\n",$idx,$filelist[$idx]&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "Hit Enter for Next Page OR Select file no to display"&lt;BR /&gt;read answer&lt;BR /&gt;case "$answer"&lt;BR /&gt;"") (( page = $page + 1 ))&lt;BR /&gt;break&lt;BR /&gt;*) if [ -n "$filelist[$answer]" ]&lt;BR /&gt;then&lt;BR /&gt;cat $filelist[$answer]&lt;BR /&gt;else&lt;BR /&gt;echo "File does not exist"&lt;BR /&gt;fi&lt;BR /&gt;echo "Press return to continue"&lt;BR /&gt;read dummy&lt;BR /&gt;break&lt;BR /&gt;esac&lt;BR /&gt;done</description>
      <pubDate>Thu, 15 Jan 2004 06:53:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165076#M160183</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-15T06:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165077#M160184</link>
      <description>The simple solution:&lt;BR /&gt;&lt;BR /&gt;clear; ll |nl |more -10&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 15 Jan 2004 07:08:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165077#M160184</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2004-01-15T07:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165078#M160185</link>
      <description>Actually, that's only the ls display part and doesn't account for file display - sorry.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 15 Jan 2004 07:10:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165078#M160185</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2004-01-15T07:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165079#M160186</link>
      <description>Hi Elmar and all for your responses.&lt;BR /&gt;   Elmar after executing your code i'm getting error at line 13.&lt;BR /&gt;&lt;BR /&gt;   Can you tell what could it be?&lt;BR /&gt;&lt;BR /&gt;Thanks ..</description>
      <pubDate>Thu, 15 Jan 2004 11:21:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165079#M160186</guid>
      <dc:creator>Ashwin_4</dc:creator>
      <dc:date>2004-01-15T11:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165080#M160187</link>
      <description>Sorry, I didn't test what I wrote, just sent the idea of how I would solve your problem. Here is a version that is tested and works... until you have more then 1024 files in the directory. But that's easy to fix with the number of array elements in the set call. But would you walk more then 100 pages of 10 files ?!&lt;BR /&gt;&lt;BR /&gt;#! /bin/ksh&lt;BR /&gt;set -A filelist 1024&lt;BR /&gt;cnt=0&lt;BR /&gt;ls *A* | while read file&lt;BR /&gt;do&lt;BR /&gt;   (( cnt = $cnt + 1 ))&lt;BR /&gt;   filelist[$cnt]=$file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo $cnt&lt;BR /&gt;&lt;BR /&gt;page=0&lt;BR /&gt;(( maxidx = $page * 10 ))&lt;BR /&gt;&lt;BR /&gt;while [ $maxidx -lt $cnt ]&lt;BR /&gt;do&lt;BR /&gt;   (( page = $page + 1 ))&lt;BR /&gt;   (( maxidx = $maxidx + 10 ))&lt;BR /&gt;   (( idx = $maxidx - 9 ))&lt;BR /&gt;   [ $maxidx -gt $cnt ] &amp;amp;&amp;amp; maxidx=$cnt&lt;BR /&gt;   while [ $idx -le $maxidx ]&lt;BR /&gt;   do&lt;BR /&gt;      printf "%4d %s\n" $idx ${filelist[$idx]}&lt;BR /&gt;      (( idx = $idx + 1 ))&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;   echo "Hit Enter for Next Page OR Select file no to display"&lt;BR /&gt;   read answer&lt;BR /&gt;   case "$answer" in&lt;BR /&gt;      "")&lt;BR /&gt;         ;;&lt;BR /&gt;      *) if [ -n "${filelist[$answer]}" ]&lt;BR /&gt;         then&lt;BR /&gt;            cat ${filelist[$answer]}&lt;BR /&gt;         else&lt;BR /&gt;            echo "File does not exist"&lt;BR /&gt;         fi&lt;BR /&gt;         echo "Press return to continue"&lt;BR /&gt;         read dummy&lt;BR /&gt;         (( page = $page - 1 ))&lt;BR /&gt;         (( maxidx = $page * 10 ))&lt;BR /&gt;         ;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2004 01:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165080#M160187</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-16T01:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165081#M160188</link>
      <description>Hi Elmar,&lt;BR /&gt;  I have 21 files in my dir. A1 to A21.&lt;BR /&gt;I'hv tested your script, which is failing to show the filename for which i have enter the sequence no.&lt;BR /&gt;./p1&lt;BR /&gt;21&lt;BR /&gt;   1 A1&lt;BR /&gt;   2 A10&lt;BR /&gt;   3 A11&lt;BR /&gt;   4 A12&lt;BR /&gt;   5 A13&lt;BR /&gt;   6 A14&lt;BR /&gt;   7 A15&lt;BR /&gt;   8 A16&lt;BR /&gt;   9 A17&lt;BR /&gt;  10 A18&lt;BR /&gt;Hit Enter for Next Page OR Select file no to display&lt;BR /&gt;&lt;BR /&gt;  11 A19&lt;BR /&gt;  12 A2&lt;BR /&gt;  13 A20&lt;BR /&gt;  14 A21&lt;BR /&gt;  15 A3&lt;BR /&gt;  16 A4&lt;BR /&gt;  17 A5&lt;BR /&gt;  18 A6&lt;BR /&gt;  19 A7&lt;BR /&gt;  20 A8&lt;BR /&gt;Hit Enter for Next Page OR Select file no to display&lt;BR /&gt;12  &amp;lt;=== Input from me.&lt;BR /&gt;So output should be "A2"&lt;BR /&gt;But it is continuing the loop again.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2004 01:51:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165081#M160188</guid>
      <dc:creator>Ashwin_4</dc:creator>
      <dc:date>2004-01-16T01:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165082#M160189</link>
      <description>Sorry... It displays the contents of the file... Can you change it yourself in the script? Second part of the case statement...</description>
      <pubDate>Fri, 16 Jan 2004 02:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165082#M160189</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-16T02:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165083#M160190</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This one simply uses the "select" function of sh. The only problem is that "Enter" redisplays current page, while any other input goes to next page (except if you select a number of course) :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;LIST=$(ls -1 | tr '\012' ' ')&lt;BR /&gt;NB=10&lt;BR /&gt;PS3="Hit N for Next Page OR Select file no to display "&lt;BR /&gt;while [ ! -z "$LIST" ]&lt;BR /&gt;do&lt;BR /&gt;  SUBLIST="$(echo $LIST | cut -d' ' -f1-10)"&lt;BR /&gt;  LIST="$(echo $LIST | cut -d' ' -f11-)"&lt;BR /&gt;  select FILE in $SUBLIST&lt;BR /&gt;  do&lt;BR /&gt;    [ -z "$FILE" ] &amp;amp;&amp;amp; break&lt;BR /&gt;    more $FILE&lt;BR /&gt;  done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2004 07:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165083#M160190</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2004-01-16T07:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165084#M160191</link>
      <description>Hi Jean-Louis,&lt;BR /&gt;         I'm getting syntax error while executing your code. Can you please test and correct it. &lt;BR /&gt;&lt;BR /&gt;Also, my kind request to you is, Do you have any tutorial for reading more about shell scripting.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2004 14:01:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165084#M160191</guid>
      <dc:creator>Ashwin_4</dc:creator>
      <dc:date>2004-01-16T14:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165085#M160192</link>
      <description>Hi Jean-Louis,&lt;BR /&gt;   OOOPS Sorry!   Your code is working fine on HP-UX, I'm getting syntax error in TRU-64 Unix. &lt;BR /&gt;&lt;BR /&gt;Please tell me where can I read about "select" command and other features of "sh"&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 16 Jan 2004 23:08:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165085#M160192</guid>
      <dc:creator>Ashwin_4</dc:creator>
      <dc:date>2004-01-16T23:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: LS Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165086#M160193</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm quite surprised about the syntax error on TRUE64. 'select' is a standard builtin command of the posix shell, so a 'man sh-posix' gives you all I know about it, including PS3 usage and so on ...&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Mon, 19 Jan 2004 02:00:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ls-script/m-p/3165086#M160193</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2004-01-19T02:00:54Z</dc:date>
    </item>
  </channel>
</rss>

