I have a particular command, that reacts differently depending on the content of the current working directory.
I now wish to pipe this program back to itself, back have the call happen in different directories.
In “pseudo-bash”, I want
command arg1 | cd /other dir | command arg2
I personally use bash, but if it helps to use a different shell, I’m open to suggestions. 🙂
I realize there is a very easy workaround with a temporary file or named pipe, but I want to know if there’s a way to do this in one command.
(…)executes a command in a subshell.cdis a shell builtin command, not a ‘real process’.( cd X ; command )will start a new sub-shell, cd into X, then runcommand.commandis running as a process, but in a different directory.Going forward it’s better to have commands that can take a directory as an argument (and if not defined, default to the current working directory). Then you could have the simple solution of
command arg1 | command --dir=/other_dir arg2