The way I have found to do this reasonably simply is using xargs, it takes a file / pipe and converts its contents into a program arguments . This can be combined with tee which splits a stream and sends it to two or more programs, In your case you need:
echo filename | tee >(xargs stat) >(xargs file) | cat
Unlike many of the other answers this will work in bash and most other shells under Linux. I shall suggest this is a good use case of a variable but if you absolutely cannot use one this is the best way to do it only with pipes and simple utilities (assuming you do not have a particularly fancy shell).
Additionally you can do this for any number of programs by simply adding them in the same manner as these two after the tee.
EDIT
As suggested in the comments there are a couple of flaws in this answer, the first is the potential for output interlacing. This can be fixed as so:
echo filename | tee >(xargs stat) >(( wait $!; xargs file )) | cat
This will force the commands to run in turn and output will never be interlaced.
The second issue is avoiding process substitution which is not available in some shells, this can be achieved by using tpipe instead of tee as so:
echo filename | tpipe 'xargs stat' | ( wait $!; xargs file )
This should be portable to nearly any shell (I hope) and solves the issues in the other commend, however I am writing this last one from memory as my current system does not have tpipe available.
<
(input from file to the left side) or|
(input from stream to the right side). There's a difference. – goldilocks yesterdayyank-last-arg
command (default shortcutMeta-.
orMeta-_
;Meta
often being the leftAlt
key) will copy the last parameter from the preceding command line into the current one. So, after executingstat fileName
you typefile [Meta-.]
and do not have to type thatfileName
again. I always use that. – Dubu 10 hours ago<
and>
are redirection, not piping. A pipeline connects two processes, while redirection simply reassigns stdin/stdout. – bdowning 1 hour ago