It depends how general you need the script to be. For the example you've given, (and generalizable to any situation where the pattern is simply an incrimenting number, you could:
Code:
#!/bin/bash
pattern="~/data/032/BRIB.Q\$n.03209000000.d"
get_missing=<insert path and script name here>
for n in $(seq 1 4); do
file=$(eval echo "$pattern")
[ ! -e "$file" ] && $get_missing "$file"
done
Since you are new to this, here is a bit of a "blow by blow" explanation of the script:
I told the script to use
bash because I've run into trouble on Ubuntu when it uses
dash for
sh. When I defined $pattern, I escaped the dollar sign on $n with a backslash so substitution was not done at that step.
seq, in this case will generate the sequence "1 2 3 4" which the
for loop will iterate through. Each time through the loop, $file will get assigned a new value based on $n. (If anybody knows of a cleaner way to do that step, please let us know.) Finally it tests for the existance of $file and if it doesn't exist, it calls your script with the missing file name. If the files you are looking for are regular files, you could use -f instead of -e. (Look at the
bash man page for information on the builtin command
test.)
More general scripts, or scripts that need to iterate through letters, will of course, be more complicated.