Possible Duplicate:Shell programming, avoiding tempfiles Say I have the file data.txt, and the command cmd.cmd takes one argument, a file. Or, you could use stdin.Now, say data.txt is uppercase, but cmd only works if all data is lowercase.Sure, you could do thistr '[:upper:]' '[:lower:]' < data.txt > lowercase_data.txtcmd lowercase_data.txtrm lowercase_data.txtBut, is there a way to integrate this?Like, a wrapper around the original file, that applies a filter, then passes a reference to the temporary file; the command is executed; last, the temporary file is deleted?I use zsh.
Avoiding temporary files in zsh
command line;zsh
zsh supports process substitution, which should do what you're asking:A command of the form =(...) is replaced with the name of a file containing its output.So for your example, to avoid manually creating a temporary file to pass the output of tr into cmd, you could saycmd =(tr '[:upper:]' '[:lower:]' < data.txt)For other shells, the equivalent would be:bash: cmd <(tr '[:upper:]' '[:lower:]' < data.txt)ksh: cmd <(tr '[:upper:]' '[:lower:]' < data.txt)rc: cmd <{tr '[:upper:]' '[:lower:]' < data.txt}Note that bash, ksh and rc implement process substitution using named pipes, rather than temporary files as zsh uses, and require the /dev/fd/ filesystem to be mounted