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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThis 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)"
.
man ls | head
... Although, head
would also be expecting command line arguments ?
man head
: With no FILE, or when FILE is -, read standard input.
. This means, that head
takes stdin if no FILE is given.
Dec 19, 2022 at 7:55
type -a ls
instead. Which is not reliable to use for what you wanrfile /usr/bin/ls
... Except, I would like to to check forwhich
at the same time, and then use the result withfile
.