I want to determine the file-type of the contents of the STDOUT output of a program (without first saving the output to a file)
i.e., notionally, I would like to run: myprogram | file
However, `/usr/bin/file can't read from STDIN.
If I try something like: my program | file <(cat /dev/stdin), I get the error broken symbolic link to pipe:[460261257]
I know I could save the output to a temp file, run file on the temp file and then erase the temp file but that seems very kludgy.
So is there any bash magic with redirection and/or file descriptors that will allow me to determine the file-type of the output of a program?
Use the
-file name to specify tofileyou want to read from stdinex.
cat myfile | file -