Artix Linux Forum

Artix Linux => Applications & Software => Topic started by: mardiyah on 11 July 2022, 05:11:44

Title: Linux way/command to make a script running from every subdir
Post by: mardiyah on 11 July 2022, 05:11:44
Sorry if not really Artix but no/little attention on many other forums

How is the find command (or else if better) to let us run a script from, i.e. relative to, every subdir under, and including, current working directory ?

illustratio e.g. script is
Code: [Select]
grep 'foo' *
Title: Re: Linux way/command to make a script running from every subdir
Post by: Lancia on 11 July 2022, 07:48:41
Sorry if not really Artix but no/little attention on many other forums

How is the find command (or else if better) to let us run a script from, i.e. relative to, every subdir under, and including, current working directory ?

illustratio e.g. script is
Code: [Select]
grep 'foo' *
I would do it this way:
Code: [Select]
find . -type d -exec sh -c 'cd {} && command' ';'