file $(ls Pictures/ | grep zip)
This command is doing three things.
First, the ls
command outputs the contents of the Pictures
searches for lines from that output that match "zip". There can be zero, one, or more filenames.
Finally, the file
command attempts to read those names that grep matches.
So try running each step in turn and see what you come up with.
Well, it turns out that the problem is with the output of ls. "ls Pictures/
" gives you a list of filenames inside Pictures, but without the full path
included. That is, you're getting file.zip
when you really need Pictures/file.zip
. So when file
tries to read them, it looks in your present working directory for them and comes up with a missing file error.
You've just discovered, as MTK358 mentioned, one reason not to parse ls for filenames.