help with bash script
Jason
ubuntu at lakedaemon.net
Wed Jul 22 00:25:07 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.
>
> - Richard.
How about this? Assuming the filenames in your list don't have spaces,
the below would accomplish your original goal. If they do, there's a
slightly different way to do it, but I'd have to dig around...
########################################################
#!/bin/bash
cd @workdir@
for fn in $(cat filelist.txt); do
@cmd@ "${fn}"
read -p "Hit a key to continue... " emptyvar
done
########################################################
hth,
Jason.
More information about the ubuntu-users
mailing list