To expand on what my colleagues RudiC and Don Cragun has already said:
I might not be (see above) the biggest expert on all things subshell but i know a thing or two about programming. Make no mistake, writing a shell script of 5 lines is essentially a programming task and it is never too early to start on healthy habits.
Programming is mostly about organizing your thoughts and the best way to organize them is to compartmentalize big problems into several smaller problems again and again until there are no problems any more. It is like moving a big heap: you take a shovel and dig one small shovel full after the other until there is no heap any more. If you try to move the whole pile you are likely to fail but with a single shovel full it is easy to succeed. One shovel - success, and another one - success again and before you notice you have the pile moved.
So, let us start with - as exactly as possible - clarify your goals: you want to get a count of (a certain type of) files within a certain subtree. Yes? (I don't mind if you respond "NO!" here, because this is what this stage is about - clarifying your goals. If i haven't understood them correctly just say so.)
You also want - because the operation might take some time - display a window telling the user to wait for completion which you want to update to tell when the counting is finished (probably, but that is my assumption, along with presenting the result). Yes?
So, first for the counting - note that we set aside everything else here! Again, shovel for shovel and we concern ourselves here with only
this shovel, not the pile and not another shovel. We can use
find for this but we can do that in a single instance because
find can traverse the filesystem (or select parts of it) on its own. To start several instances of
find and then compile their results is simply not necessary. In addition to what RudiC and Don Cragun already said you find a more thorough
introduction to find here. See how far that gets you and ask if you still have questions.
There is another question to this: how is the result of this operation propagated to whereever you will need it. I will postpone that for the moment because the rest of the operation is not clear yet.
Second is the business with the user notification. I told you above that the basic logic of this is to:
- present a user the initial window with a "please wait..."-message
- run the
find-operation
- replace the "please wait...."-message with something else (i.e. a "done" or "result is:..."-message)
This is basically the same as what RudiC (and myself) earlier have already suggested. For this you do not need any pipes, background processes or anything else of that sort as Don Cragun has already explained.
So, if you want help for the further commencement of this, you are welcome to more clearly describe your goals and we can take it from there.
I hope this helps.
bakunin