I am wanting to build a custom builtin in bash -- like time for example. Is this possible? If it's not, is it possible in another shell?
For example, I want to do this: map find -name '*.js' | xargs grep func1 and have it run find -name '*.js' | xargs grep func1 inside every directory within CWD. Notice that everything including the pipe gets passed to map.
The goal is to apply a command across multiple directories. I wrote a script called map which evals $1 across whatever ls produces. However, if the command I want to run includes pipes, redirects, etc, then I have to quote everything inside a string. I am looking for a way to not have to do that.
Also, I'm just plain curious if this is possible ;)
-execforfindthen though and do away with the pipe (and need to handle quoting which your version doesn't do right now)map $(find $BASE_DIR -type d)?alias map='find . -print0 -name \*.js | xargs -0 grep func1'?evalto parselsoutput seems generally unsafe -- it'd be safe only so long as it's known for certain the filenameslsoutputs aren't mischievous.