help with bash script

Rashkae ubuntu at tigershaunt.com
Tue Jul 21 22:23:29 UTC 2009


R Kimber wrote:
> I'm trying to do something very simple but failing, and would appreciate
> some pointers.
> 
> I'm trying to create a script that executes a command on a series of files
> one-at-a-time, pausing between each execution.  The input files are all in a
> single file, one on each line. I have
> .......................
> #!/bin/bash
> cd <to working directory>
> cat <file with list of input files> | while read FILECHECKED do
> 
>    <command> "$FILECHECKED"
>    echo
>    RESPONSE="Z"
>    echo -n Press a key to continue....
>    while [ "$RESPONSE" = "Z" ]
>    do
>       read RESPONSE
>    done
>    echo
> done
> ......................
> 
> The command executes, but there is no pause between the processing of each
> input file.  I've tried various variations using the read command, to no
> avail.  Curiously, if I add
> echo "$FILECHECKED" and "$RESPONSE"
> just before the final 'done', it prints out the name of the file it has
> just processed and the file it is about to process - not 'Z'.
> 
> I'm obviously doing something stupid.
> 

I'm not at all sure how I would go about doing what you are trying to
do, but I can tell you why your script is gone awry

The stdout from the cat command is getting picked up by the inner loop
read command, therefore, the current script is only doing it's operation
on every other file.




More information about the ubuntu-users mailing list