My Suse

What I have learn so far about Linux and Suse

Tuesday, October 17, 2006

Learn how to open all ebooks of one subject at same time

You'll learn:
  • how to run async commands
  • how to find and open several documents at same time
Let's supose that you are studying Python, and you want to open all of your ebooks about python, here's the first ideia of how to do it:

find . -iname "*python*.pdf" -exec xpdf {} \& \;

But, as you can verify it will open all the documents but only one at time. So here's the complete solution:

find . -iname "*python*.pdf" -print0 | xargs -0 -i bash -c "xpdf \"{}\" &"

If you're playing with xargs try use it with -p to see what it is doing.

You could be asking "Why not just something like xpdf *.pdf?". Well, there are viewers that doesn't support multiple file arguments. It only opens one file at time, like the kchmviewer:

find . -iname "*python*.chm" -print0 | xargs -0 -i bash -c "kchmviewer \"{}\" &"

0 Comments:

Post a Comment

<< Home