6 ms·
With bash putting a command in <() uses the output of the command as though it were a file. I use it to diff the output of two commands: diff <(command 1) <(co
by despite2 15y ago
With bash putting a command in <() uses the output of the command as though it were a file. I use it to diff the output of two commands: diff <(command 1) <(command 2)
I've never used it, but I assume >() uses a command as though it were a writable file. So instead of history -a file writing to file, he does history -a >(logger) to write to the logger command. Seems pretty clever to me.
- zooz 15y agoYup, that's what it does. Shortly speaking <() or >() in bash that creates a temporary pipe.
- sciurus 15y agoIt's called process substitution. In this case it runs the logger command, connects its input to a file in /dev/fd, and places the name of that file in the argument list of history. I've included a small demonstration below. This is useful since the history command won't write to standard out so you can't use a normal pipe. It's more common to see process substitution used to gather output from multiple commands, see http://www.linuxjournal.com/content/shell-process-redirection http://www.linuxjournal.com/content/shell-process-redirectio... $ cat writer.sh #!/bin/bash if [[ "$#" == 1 ]]; then echo "Wrote to file named $1" > "$1" else echo "Wrote to stdout" fi $ ./writer.sh Wrote to stdout $ ./writer.sh | cat Wrote to stdout $ ./writer.sh >(cat) Wrote to file named /dev/fd/63