nesting a statement in a loop
I have a list of values and want to loop an ls -ltr over them to see that they are populated.
If they are not populated, I want to know that too. I want to make sure that there is something there. So i echo out the value it goes like this : Code:
for i in broker1 broker2 energy external1 trader1 trader2; So that way I can see which broker statements directories are not populated i have been doing the same script for years. Is there a different way of accomplishing this - a different way of nesting the search in the loop? My scripting needs to evolve. |
Hi casper,
Is there something that this script isn't doing that would improve your day? For example, you could extend it to just report the directories that don't contain anything: Code:
populated=$(ls /production/archive/production/web/docs/$i/docs/etc/etc_html/ | wc -w) On the other hand, if this script is already meeting your needs, why not think through other tedious regular tasks, and find one of those that could be scripted. Of course, there are always different ways of doing something. Sometimes, though, the other ways are more... stupid than what you already have. If it ain't broke, don't fix it. |
Don't parse the output of ls. Just use the find command.
Code:
for i in broker1 broker2 energy external1 trader1 trader2; |
|
All times are GMT -5. The time now is 06:38 PM. |