Hello Bash Superheros,
I am trying to create a simple bash function that pipes the output from find to a a pdf viewer, similar but limited to evince.
function findpapers {
find ~/papers/ -name *$1* | evince
}
The above function opens the viewer but does not display any of the desired files/paths. Ultimately, I would like to display all the pdf's outputted from find. A simple find command such as:
$ find /home/alex/papers/ -name *erebus*
creates an output like:
/home/alex/papers/2000/rowe/seismic_and_acoustic_observations_at_mount_erebus_volcano_ross_island_antarctica.pdf
/home/alex/papers/2008/Jones/infrasonic_tracking_of_large_bubble_bursts_and_ash_venting_at_erebus_volcano_antarctica.pdf
Then the idea is to display those two pdf files in a viewer.
Any ideas or suggestions? I am using Linux Mint if that helps. Thanks heaps in advance!
You want the list of file names on the command line of evince, not in its standard input.
Use
evince $(find /home/alex/papers/ -name *erebus*)
or
find /home/alex/papers/ -name *erebus* | xargs evince
On linux (or any OS that uses the gnu versions of find and xargs) , if there is any chance the file names might contain spaces, better use
find /home/alex/papers/ -name *erebus* -print0 | xargs -0 evince