Issue
Say I have a unique file somewhere called file.ext
.
It is indexed by my Ubuntu box, so the command locate file.ext
correctly gives me the (single) location, say /usr/local/some/place/file.ext
.
So I thought that this:
locate file.ext | xdg-open
would open the file with the default application associated with the file type (there is one, that is not the problem), just as if I have entered xdg-open /usr/local/some/place/file.ext
Instead, I get the "usage" message coming from xdg-open
, as if it was called without arguments.
So the question is: did I get something wrong about pipes? Or this some issue with that particular command?
Solution
Because you have to pass filename as option, and not data on stdin. Use xargs for that:
locate file.ext | xargs xdg-open
or just subshell:
xdg-open "$( locate file.ext )"
Answered By - user80168 Answer Checked By - David Goodson (WPSolving Volunteer)