<div dir="ltr">2014-06-02 17:35 GMT+02:00 John Howe <span dir="ltr"><<a href="mailto:madlinuxman@hotmail.com" target="_blank">madlinuxman@hotmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
    <div>On 01/06/14 23:10, Johnny Rosenberg
      wrote:<br>
    </div>
    <blockquote type="cite">
      <pre>I have something like this:
while read -r -a Line; do
    …
    …
done << "$SomeFile"

Since my script are going to do some dangerous things (deleting files –
hopefully the right ones), I first want to test it by omitting the
dangerous lines and adding a lot of echo lines, letting me know the values
of all important variables.
$SomeFile has a few thousands of lines, so I don't want to go through it
all, but I would like to see the result of maybe the first 20 lines or so.

So I want the script to stop before looping, letting me study all the
variables before going to the next line in the file.

But I figure that if I use ”read” to do that, that ”read” command would
also be fed with $SomeFile, wouldn't it?

So I want something like this:
while read -r -a Line; do
    …
    …
    echo "Press any key to continue"
    SomeCommand
done << "$SomeFile"</pre></blockquote></div></div></div></blockquote><div>Ooops, I guess I accidently added a ”<” too much…</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5"><blockquote type="cite"><pre>


</pre>
      <br>
      
      <br>
    </blockquote></div></div>
    I use.........<br>
    <br>
    # init<br>
    function pause(){<br>
       read -p "$*"<br>
    }<br>
    <br>
        do some work here<br>
    <br>
    read -p "Press [Enter] key to continue or Crtl c to exit..."<br></div></blockquote><div><br></div><div>I suppose you mean ”pause” instead of ”read -p”, right? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
    <br>
    Hope it helps<span class=""><font color="#888888"><br></font></span></div></blockquote><div><br></div><div>Maybe it should, but it doesn't seem to work the way I was talking about in my original post. Here's are my test files:</div>
<div><File></div><div># looptest.sh</div><div>#!/bin/bash<br><br>function pause(){<br>    read -p "$*"<br>}<br><br>while read x; do<br>    echo $x<br>    pause "Press any key to continuea"<br>done < Information</div>
<div></File></div><div><br></div><div><File></div><div># Information</div><div>This<br>text<br>is<br>very<br>very<br>interesting<br>annoying</div><div></File></div><div><br></div><div><Execution></div>
<div>$ ./looptest.sh<br>This<br>is<br>very<br>annoying<br>$</div><div></Execution></div><div><br></div><div>The text is printed immediately, no pause or anything. So it seems, just like I said in my original post, like the file (”Information” in this case) does the input for me. Is there a way to force a read command to read from the keyboard in a situation like this?</div>
<div><br></div><div><br></div><div>Johnny Rosenberg</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class=""><font color="#888888">
    <br>
    <pre cols="72">-- 
Best Regards
John

*Windows users take note: all emails from this system are scanned for viruses using ClamAV and the latest definitions*</pre>
  </font></span></div>

<br>--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
<br></blockquote><br></div>