this post was submitted on 20 Dec 2025
25 points (100.0% liked)

Linux

10710 readers
323 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
 

I was trying to find all symbolic links in /usr/lib and use file on the first entry in the list, which I delimited with head -n 1.

Why does find /usr/lib -maxdepth 1 -type l | file $(head -n 1) work but find /usr/lib -maxdepth 1 -type l | head -n 1 | file does not?

It complains that I am not using file correctly. Probably because it lacks an argument, but - programmatically/syntactically - why can't file grab it's argument from the pipe?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] Piatro@programming.dev 18 points 1 day ago (1 children)

Your syntax is fine, but not all commands/programs accept input from the pipe, or more accurately from stdin. Looking at the man page for file (https://www.man7.org/linux/man-pages/man1/file.1.html) I can't see a stdin option, so you have to pass each of the files from your head output as arguments to file.

Thanks! Yeah, I just came to the realization that this was more about my lack of understanding of the file command than anything else.