I'm having difficulty grasping how pipes work. Initially I thought of them as per the title but I couldn't get a simple example to work e.g.
mkdir temp cd temp echo "rubbish" > txtfile ls | cat txtfile # why does it not return "rubbish"? ls | cut -c 2-4 xtf # result I expected.
I've read many pipe tutorials but none of them seem to go beyond "STDOUT of LHS becomes STDIN for RHS" and I'm left wondering what is STDIN of RHS. Does it become the first argument? Where does it slot in when RHS of pipe has options or more than one argument. Is there any kind of macro substitution taking place or is my thinking wide of the mark.
Given the above examples, does cut take its input from stdin but cat doesn't? How do you know which commands take their input from stdin and which don't?