Search code examples
fileunix-ar

Redirect output to 'file' command


Is there any way to have the file command get it's input from stdin? Specifically, I am trying to get the file type of a file in an archive, and am trying to do it in a single command. I tried this:

ar -p foo.a baz.o | file

but that does not work.


Solution

  • Use file -. The hyphen means "take input from standard input".