<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I hope I'm not becoming a bother.  If I am, just let me know and I'll find another list to post my BASH questions on.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Anyway, I am still having a little trouble scripting.  I don't quite understand tests (when to use == or -eq, for example).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If any of you could look at my code, I'd appreciate it.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#!/bin/bash</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#************************************************#</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#                 file_prompt.sh                 #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#        written by Matthew Strax-Haber          #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#             Started June 19, 2005              #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#          Last Modified June 26, 2005           #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#                                                #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#         Lists files in a dir and asks          #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#            the user which to select            #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#************************************************#</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_FILE_DOES_NOT_EXIST=85</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_PERM_DENIED=87</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_FILE_NOT_DIR=88</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_NEED_ARGS=95</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_INVALID_USER_INPUT=98</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">work_dir=$1                     # directory to work in</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">prompt=${2-"Choose"}            # prompt to show user</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">full_pathQQQ=$3                 # whether output should be full path</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#chosen_num                     # Num from prompt</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#chosen_file                    # Name of chosen file</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">max_tries=3                     # Max num of prompts if invalid file selected</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if test -z $work_dir -o -z "$prompt"</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  Missing arguments!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_NEED_ARGS</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -e $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  \"$work_dir\" does not exist!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_FILE_DOES_NOT_EXIST</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -d $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  \"$work_dir\" is not a directory!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_FILE_NOT_DIR</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -x $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  You do not have permission to list the files in \"$work_dir\"!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_PERM_DENIED</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if test -z $full_pathQQQ</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   full_pathQQQ=1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"># --------------------------------------------------------- #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"># --------------------------------------------------------- #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">command ls $work_dir | grep -n -v 'randtonotmatch' | column > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">num_files=$(command ls $work_dir | grep -c -v 'randtonotmatch')</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">digits=1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">while (( $num_files >= 10 ))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> do</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   ((digits += 1))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   ((num_files /= 10))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> done</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">tries=0</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">while [ ! -e "$chosen_file" -o $tries != $max_tries ]</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> do</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   read -p "$prompt:   " -n $digits chosen_num > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   chosen_file=$(command ls $work_dir | grep -n -v 'randtonotmatch' | grep ^$(($chosen_num)): | cut -d ":" -f 2-)</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   if [ ! -e $chosen_file ]</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">    then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">      ((tries += 1))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">      echo -e "\nInvalid file selection!  You have $((max_tries - tries)) left."</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">done</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if (( $max_tries = $tries ))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  You have repeatedly chosen an invalid file!  This program will now quit." > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_INVALID_USER_INPUT</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#      echo "$(basename $0):  The chosen file does not exist!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">echo " - $chosen_file" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">echo $chosen_file >&1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"></SPAN></FONT></DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Also, what would be the best way to have a timeout period on prompts using the command "read"?  I want it to automatically choose what the user has entered after 0.5 seconds.  This is actually for a different script.  Also, if possible, it would be nice to have that timeout period restart if the user types anything.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thank you very much to anyone who responds.</DIV><DIV>~Matt</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>PS: In case it would help, here is the version of this from before I tried to implement "retries".</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#!/bin/bash</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#************************************************#</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#                 file_prompt.sh                 #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#        written by Matthew Strax-Haber          #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#             Started June 19, 2005              #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#          Last Modified June 23, 2005           #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#                                                #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#         Lists files in a dir and asks          #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#            the user which to select            #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#************************************************#</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_FILE_DOES_NOT_EXIST=85</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_PERM_DENIED=87</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_FILE_NOT_DIR=88</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">E_NEED_ARGS=95</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">work_dir=$1                     # directory to work in</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">prompt=${2-"Choose"}            # prompt to show user</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">full_pathQQQ=$3                 # whether output should be full path</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#chosen_num                     # Num from prompt</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">#chosen_file                    # Name of chosen file</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if test -z $work_dir -o -z "$prompt"</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  Missing arguments!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_NEED_ARGS</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -e $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  \"$work_dir\" does not exist!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_FILE_DOES_NOT_EXIST</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -d $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  \"$work_dir\" is not a directory!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_FILE_NOT_DIR</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">elif test ! -x $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo "$(basename $0):  You do not have permission to list the files in \"$work_dir\"!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   exit $E_PERM_DENIED</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if test -z $full_pathQQQ</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   full_pathQQQ=1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"># --------------------------------------------------------- #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"># --------------------------------------------------------- #</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">if test -O $work_dir -a -d $work_dir</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"> then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   command ls $work_dir | grep -n -v 'randtonotmatch' | column > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   num_files=$(command ls $work_dir | grep -c -v 'randtonotmatch')</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo $num_files > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   digits=1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   while (( $num_files >= 10 ))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">    do</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">      ((digits += 1))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">      ((num_files /= 10))</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">    done</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   read -p "$prompt:   " -n $digits chosen_num > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   chosen_file=$(command ls $work_dir | grep -n -v 'randtonotmatch' | grep ^$(($chosen_num)): | cut -d ":" -f 2-)</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   if [ ! -e $chosen_file ]</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">    then</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">      echo "$(basename $0):  The chosen file does not exist!" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   fi</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo " - $chosen_file" > /dev/stderr</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">   echo $chosen_file >&1</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Courier New" size="3"><SPAN class="Apple-style-span" style="font-size: 11px;">fi</SPAN></FONT></DIV></BLOCKQUOTE></DIV></BODY></HTML>