DEV Community

Discussion on: My Shell Workflow: Executing a command in lots of directories.

Collapse
 
val_baca profile image
Valentin Baca • Edited

Very nearly the same, here's my "inall" script:

$ cat ~/bin/inall
#!/bin/sh
# runs given command (all arugments) in each directory of pwd
# example: in a workspace directory with many subfolders:
# $ inall git status

echo $@
for dir in ${PWD}/*
do
    if [ -d $dir ]; then
        echo ""
        echo "$dir"
        cd $dir && $@
        cd - > /dev/null
    fi
done
Collapse
 
shriharshmishra profile image
Shriharsh

cool! neater than what I used!