Though Pantry may be used in conjunction with many other Unix shell utitlities, you may find GNU Screen to be particularly useful. screen is so useful with Pantry due to its advanced cutting-and-pasting capabilities. Here is a good introduction to screen. Most Linux systems will already have screen installed; if not, you'll be able to install it using your distribution's package manager.
Pantry includes the paste
report, which makes screen
particularly useful. Often in Pantry, you will be
searching your master
file, not
entirely sure what food you are looking for. On
other occasions, you will know what you are looking
for, but your search terms return a lot of results
to scroll through--and the food that you want has a
very long name that you do not want to have to
retype. Using the paste
report, you can easily reuse your search results.
The paste
report prints
one line for each available unit for each food. The
results include the -x
,
-n
, and -U
options, and the results are also quoted so you may
easily paste them into a subsequent
pantry command.[11]
To see how powerful this is, we can return to our
earlier example of finding how many calories are in
an apple. You would likely start by searching the
master
file for the name trait
apple
. As we saw earlier,
this returns 163 results:
Example 4.22. Searching for apple
returns 163 results
$
pantry --ignore-case --name apple --print names master
Babyfood, cereal, oatmeal, with applesauce and bananas, junior HEALTHY CHOICE Traditional Meat Loaf w/Brown Sauce, Mashed Potatoes, Green Beans and Apple Praline Crisp, frozen meal Pie, apple, commercially prepared, enriched flour Apples, dried, sulfured, stewed, without added sugar Babyfood, dessert, fruit pudding, pineapple, strained Cereals ready-to-eat, GENERAL MILLS, OATMEAL CRISP, APPLE CINNAMON Cereals ready-to-eat, QUAKER, QUAKER APPLE ZAPS VERYFINE APPLE QUENCHERS Apple Raspberry Cherry Juice Cocktail, ready-to-drink Cereals, QUAKER, Instant Oatmeal, NUTRITION FOR WOMEN, Apple Spice, dry English muffins, raisin-cinnamon (includes apple-cinnamon) Babyfood, cereal, rice, with applesauce and bananas, strained Babyfood, cereal, oatmeal, with applesauce and bananas, strained Pineapple, raw, extra sweet variety Cereals ready-to-eat, KELLOGG, KELLOGG'S APPLE CINNAMON SQUARES MINI-WHEATS Custard-apple, (bullock's-heart), raw [ trimmed to save space ]
Earlier we limited our search results by typing
subsequent pantry commands and
tweaking the --name
argument. When
we zeroed in on the food we wanted, we typed yet
another pantry command, this time
to figure out the available units. Finally, we typed
another pantry command to change
the unit and quantity to what we wanted and to print
the nutrient information for a single large apple.
You can do this using many fewer commands with
screen and the
paste
report. After firing up
screen, type a
pantry for what you are looking
for. I also use sort because I
find it easier to scan results when they are
alphabetized.
Example 4.23. Using the paste
report
$
pantry --ignore-case --name apple --group fruit --print paste master | \
>
sort
-x -n 'Apple juice, canned or bottled, unsweetened, with added ascorbic acid' -U 'cup' -x -n 'Apple juice, canned or bottled, unsweetened, with added ascorbic acid' -U 'fl oz' -x -n 'Apple juice, canned or bottled, unsweetened, with added ascorbic acid' -U 'g' -x -n 'Apple juice, canned or bottled, unsweetened, with added ascorbic acid' -U 'lb' -x -n 'Apple juice, canned or bottled, unsweetened, with added ascorbic acid' -U 'oz' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'cup' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'drink box (8.45 fl oz)' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'fl oz' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'g' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'lb' -x -n 'Apple juice, canned or bottled, unsweetened, without added ascorbic acid' -U 'oz' -x -n 'Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water, with added ascorbic acid' -U 'cup' -x -n 'Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water, with added ascorbic acid' -U 'fl oz' -x -n 'Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water, with added ascorbic acid' -U 'g' -x -n 'Apple juice, frozen concentrate, unsweetened, diluted with 3 volume water, with added ascorbic acid' -U 'lb' [ trimmed to save space ]
Now you can scroll through the results using Screen's commands; copy the line you are interested in to Screen's paste buffer. For more details on how to do this, consult the Screen manual page under "copy". Pay particular attention to the J command, which joins lines--this is useful if a particular line is so long that it does not fit on one line in your terminal.[12]
After finding the result you are interested in, you can easily paste it in to a new command line and add the options you need.
[11] Actually, the results are quoted so they may
be pasted into shells that have Bourne-like
syntax, such as bash,
zsh, and
fish. I don't know
enough about csh-like
shells to know if the
paste
report works with
them.
[12] You don't have to use screen; you can copy and paste using your terminal emulator if you wish. Though I think screen is easier to use, you might diasgree...