I want to write a script that will run a certain commands on my subdirectories with names containging or rather end with some strings, say, *-nom1
, *-nom2
, *-nom3
. i.e.
for dir in $(subs)
do
// do something in this dir
done
my question is, would this be the way to list my sub-directories, if not what's the best way to do it:
subs = find -maxdepth 2 -type d -name '*-nom1'
&& find -maxdepth 2 -type d -name '*-nom2'
&& find -maxdepth 2 -type d -name '*-nom3'
I can test it on my Ubuntu
terminal and it seems to work.
my script will be running on Debian
if that helps.
for dir in */*-nom[123]
? What does the directory tree structure look like? – Gilles 'SO- stop being evil' Nov 26 '16 at 14:31nom1
,nom2
,nom3
are just examples. – rethabile Nov 28 '16 at 09:35