14.6.2. Reading HTML documentation for a package
You can combine the rpm command with other commands as well. For example, the rpm –qd command lists the documentation files with a package. If this documentation is in HTML format, you can display this documentation in a Web browser such as Mozilla. Furthermore, by convention, the starting page for HTML documentation should be a file named index.html. Listing 15-5 combines all these factors:
Listing 15-5: rpmmoz
#!/bin/sh
html_file=`rpm -qd $* | grep index.html | head -n 1 `
echo "Launching Web browser with $html_file"
htmlview $html_file &
This script searches for the documentation for a given package name, finds the first file named index.html, and launches the Web browser in the background to display this file, using the htmlview command which will likely run mozilla or your configured Web browser. When you run this command, you should see output like the following; then the Web browser should appear:
$ ./rpmmoz rpm-devel
Launching Web browser with /usr/share/doc/rpm-devel-4.1/apidocs/html/index.html
Note
This script does not check for errors. If there are no files named index.html, the script launches the Web browser anyway. You could fix this by changing the script to validate the html_file variable prior to launching the Web browser.