Let's say /tmp
has subdirectories /test1
, /test2
, /test3
and so on,
and each has multiple files inside.
I have to run a while
loop or for
loop to find the name of the directories (in this case /test1
, /test2
, ...)
and run a command that processes all the files inside of each directory.
So, for example,
I have to get the directory names under /tmp
which will be test1
, test2
, ...
For each subdirectory, I have to process the files inside of it.
How can I do this?
Clarification:
This is the command that I want to run:
find /PROD/140725_D0/ -name "*.json" -exec /tmp/test.py {} \;
where 140725_D0
is an example of one subdirectory to process - there are multiples, with different names.
So, by using a for
or while
loop, I want to find all subdirectories and run a command on the files in each.
The for
or while
loop should iteratively replace the hard-coded name 140725_D0
in the find command above.