Redirect output to 'file' command

129 views Asked by At

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.

2

There are 2 answers

0
200_success On BEST ANSWER

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

1
Soroosh Sarabadani On

Try this one:

ar -p foo.a baz.o | xargs file