How to pipe in the result of another UNIX command

user1610862 picture user1610862 · Aug 31, 2012 · Viewed 13.7k times · Source

Right now I'm using another text file to store the result of one UNIX command and then using that file to run another command, like so:

tr -d "[,|.]" < text > temporary.txt
tr "[A-Z]" "[a-z]" < temporary.txt > result.txt

How do I combine these two into a single line so that I don't have to use a temporary file? The following does not work:

(tr "[A-Z]" "[a-z]" < (tr -d "[,|.]" < text)) > result.txt

I know how to use && but that still requires the use of a temporary holder file.

Possible duplicate: Bash: how to pipe each result of one command to another

Answer

perilbrain picture perilbrain · Aug 31, 2012

Pipes are your friend:-

cat text | tr -d "[,|.]" | tr "[A-Z]" "[a-z]" >result.txt