0

I would like to use the result of which ls and see the file type using file. However, when I type in which ls | file it doesn't work. When I try to do file < which ls, that doesn't work either.

Any pointers would be appreciated.

Grateful
  • 113
  • 2
  • Use `type -a ls` instead. Which is not reliable to use for what you wanr – Valentin Bajrami Dec 19 '22 at 07:24
  • @ValentinBajrami Thank you for trying to answer, but I was looking for the result of `file /usr/bin/ls`... Except, I would like to to check for `which` at the same time, and then use the result with `file`. – Grateful Dec 19 '22 at 07:29
  • 1
    Does this answer your question? [whereis, pipline and ls](https://unix.stackexchange.com/questions/364079/whereis-pipline-and-ls) – muru Dec 19 '22 at 07:43

1 Answers1

2

This does not work because file takes the file to examine as commandline parameter (see man file).

You are piping the output of which to the stdin of the process executing ls.

What you should do is something like file "$(which ls)".

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
gerhard d.
  • 2,168
  • 12
  • 21