I have 35 distinct directories, named case1 to case35 respectively. I have the same shell script in each of them and I was wondering if there is a way to execute it in every directory at once.
Asked
Active
Viewed 954 times
0
-
I am using csh rather than bash – JXS832 Jan 14 '14 at 02:31
-
You want to execute 35 scripts in different directories or you want to execute 1 script that runs on 35 directories? – John3136 Jan 14 '14 at 02:31
-
I want to execute the same script 35 times. So I want to execute it once in every directory – JXS832 Jan 14 '14 at 02:36
1 Answers
0
In csh
:
foreach d (case*)
$d/script &
end
Or you can use sh
/bash
which gives a better programatic interface:
for d in case*; do $d/script & done
Add a cd
before running the script if you want to be in the directory when executing the script.

verdammelt
- 922
- 10
- 22