I'm trying to us bash scripting to batch execute an existing package. The input for each execution requires two input files. I can either use regular names or place each pair in its own sub-directory to make sure each pair stays together. I've got bits and pieces but nothing that loops over TWO files or enters a sub-directory, does something, moves up and repeats on the next sub-directory.
This will perform what I want on a single directory containing the pair of files (each file pair is named e.g. ABC10f.txt
and ABC10r.txt
):
#!/bin/bash
#
f=$(ls *f.txt)
echo "forward -> $f"
i=$(ls *r.txt)
echo "reverse -> $i";
/path/to/package [options] $f $i;
The following will loop through each sub-directory in my main directory but only executes what I only when it gets to the last one (Note: I was testing it with helloworld.sh
– I thought if I could get it to list each sub-dir and echo "hello world" after each I'd be on my way to doing what I want; instead I get a list of all sub-directories followed by a single "hello world"):
#!/bin/bash
#
myCommand=/path/to/scripts/helloworld.sh
for d in ./; do
find * -maxdepth 1 -type d
cd $d
echo $PWD
exec "$myCommand"
done
A little help putting this together?