Cdexec v0.1

Just released a small tool to “foreach” over a selection of
directories running a common command.

I’m sure there’s a number of ways to do the same thing with shell
coreutils, but my search turned-up nothing quite as concise as I
wanted. But do let me know if you know of any (if there turns out to
be a concise way I did not know about, I would rather use standard
tools, of course!)

A simple example of use is:

$ cdexec * - ls -1

Which produces a list of files in all sub-directories.

This is a very early release with no additional options.

gem install cdexec

On GitHub: GitHub - rubyworks/cdexec: Change and execute in each directory

Thomas S. wrote in post #1018930:

Just released a small tool to “foreach” over a selection of
directories running a common command.

I’m sure there’s a number of ways to do the same thing with shell
coreutils, but my search turned-up nothing quite as concise as I
wanted. But do let me know if you know of any (if there turns out to
be a concise way I did not know about, I would rather use standard
tools, of course!)

pssh and/or parallel might help, but I’m not sure :slight_smile:

On Sun, Aug 28, 2011 at 8:14 PM, Intransition [email protected]
wrote:

I’m sure there’s a number of ways to do the same thing with shell
coreutils, but my search turned-up nothing quite as concise as I
wanted. But do let me know if you know of any (if there turns out to
be a concise way I did not know about, I would rather use standard
tools, of course!)

find, from findutils, has -exec. It is very handy when it comes to
iterating
and processing files and directories with many options.

The following will pass all files in the current directory that have
been
modified in the past 20 days through the processing_script:

$ find . -type file -mtime -20 -exec processing_script {} ;

HTH,
Ammar