help with bash script
Smoot Carl-Mitchell
smoot at tic.com
Tue Jul 21 22:48:01 UTC 2009
On Tue, 2009-07-21 at 22:30 +0100, 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'.
The read commands are interfering with each other because you redirected
input into the while loop read. Change
read RESPONSE
to
read RESPONSE </dev/tty
You also need a ";" after the first read RESPONSE or put the "do" on a
separate line.
Cheers
--
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005
More information about the ubuntu-users
mailing list