Reading a file more than once in a shell script

From: Bernie (bpw4h_at_yahoo.com)
Date: 07/27/04


Date: 26 Jul 2004 15:58:09 -0700

Hi,

I was wondering if there was a way to read in a file more than once in
a shell script. I'm not sure how else to explain it, so it might be
easier to understand if you look at the script:

for a in 1 2 3 4
do
  while read -r INPUT_LINE
  do
    <commands>
  done < ${SOURCE_FILE}
done

This seems to be giving me some problems that I can quite figure out
how to solve. After the first read through of the SOURCE_FILE, I
basically want to start over and read it again. Is there a way to
"reset" the SOURCE_FILE? Running the above script gives me one good
output, and then the rest of the output is incorrect.

Thanks.
Bernie



Relevant Pages

  • Re: Check POP3 E-mail
    ... serves a purpose. ... memory unless it is reset when you run under mod_perl. ... >> start of the script emptying any data left over from the previous ... It ISN'T incorrect at all. ...
    (comp.lang.perl.misc)
  • Re: pop-forum Re: poplog-dev A look at Poplog on the Macintosh
    ... with the poplink command. ... When trying to make pglink produce a 'sh' rather than a 'csh' shell ... script for linking and when trying to make it put unexpanded environment ... using the shell script pglibr, ...
    (comp.lang.pop)
  • Files appear to be cross linked
    ... script requires a number of standard environment variables to be set ... so it calls a second shell script to set these at the session level, ... control should return to the first shell script, ... that the script executes to the last line prior to the displaying of ...
    (comp.unix.solaris)
  • Re: [PHP] Catch STDERR
    ... into your PHP script? ... Or do you just need STDOUT in one variable, and STDERR in another, ... Another option is to try to write a .sh shell script to get what you ...
    (php.general)
  • Re: basic questions
    ... Setting a script that runs at 3:00 ... Set chron to run that shell script. ... Debug the GUI application with the REPL. ... You start up the Web browser, then browse the Web, visit a hundred ...
    (comp.lang.lisp)