100% found this document useful (1 vote)
85 views

[FREE PDF sample] Mastering Linux Shell Scripting a practical guide to Linux command line Bash scripting and Shell programming Ebrahim ebooks

Linux

Uploaded by

saksidisson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
85 views

[FREE PDF sample] Mastering Linux Shell Scripting a practical guide to Linux command line Bash scripting and Shell programming Ebrahim ebooks

Linux

Uploaded by

saksidisson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Download the full version of the textbook now at textbookfull.

com

Mastering Linux Shell Scripting a practical


guide to Linux command line Bash scripting
and Shell programming Ebrahim

https://textbookfull.com/product/mastering-linux-
shell-scripting-a-practical-guide-to-linux-
command-line-bash-scripting-and-shell-programming-
ebrahim/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Mastering Linux shell scripting a practical guide to Linux


command line Bash scripting and Shell programming Second
Edition. Edition Mokhtar Ebrahim
https://textbookfull.com/product/mastering-linux-shell-scripting-a-
practical-guide-to-linux-command-line-bash-scripting-and-shell-
programming-second-edition-edition-mokhtar-ebrahim/
textbookfull.com

Linux Shell Scripting Cookbook - Third Edition Clif Flynt

https://textbookfull.com/product/linux-shell-scripting-cookbook-third-
edition-clif-flynt/

textbookfull.com

BASH SCRIPT Linux Command Line Reference 1st Edition


Aditya Tiwari

https://textbookfull.com/product/bash-script-linux-command-line-
reference-1st-edition-aditya-tiwari/

textbookfull.com

Fullstack D3 and Data Visualization Build Beautiful Data


Visualizations and Dashboards with D3 Amelia Wattenberger

https://textbookfull.com/product/fullstack-d3-and-data-visualization-
build-beautiful-data-visualizations-and-dashboards-with-d3-amelia-
wattenberger/
textbookfull.com
Design and Analysis of Experiments with R Ninth Edition
John Lawson

https://textbookfull.com/product/design-and-analysis-of-experiments-
with-r-ninth-edition-john-lawson/

textbookfull.com

China's Expansion in International Business: The


Geopolitical Impact on the World Economy Peter Baláž

https://textbookfull.com/product/chinas-expansion-in-international-
business-the-geopolitical-impact-on-the-world-economy-peter-balaz/

textbookfull.com

The Quality Agenda in Early Childhood Education


Questioning Local and Global Policy Perspectives Elise
Hunkin
https://textbookfull.com/product/the-quality-agenda-in-early-
childhood-education-questioning-local-and-global-policy-perspectives-
elise-hunkin/
textbookfull.com

The Palgrave Handbook of Prison and the Family Marie


Hutton

https://textbookfull.com/product/the-palgrave-handbook-of-prison-and-
the-family-marie-hutton/

textbookfull.com

The Gun digest 2016 70th Edition Jacobs

https://textbookfull.com/product/the-gun-digest-2016-70th-edition-
jacobs/

textbookfull.com
Toxicology and Biological Monitoring of Metals in Humans
Including Feasibility and Need Bonnie L. Carson

https://textbookfull.com/product/toxicology-and-biological-monitoring-
of-metals-in-humans-including-feasibility-and-need-bonnie-l-carson/

textbookfull.com
Mastering Linux Shell Scripting
Second Edition

A practical guide to Linux command-line, Bash scripting, and Shell


programming

Mokhtar Ebrahim
Andrew Mallett
BIRMINGHAM - MUMBAI
Mastering Linux Shell
Scripting Second Edition
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, without the prior written permission of the publisher, except in the case of brief
quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express or implied.
Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages
caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the
accuracy of this information.

Commissioning Editor: Vijin Boricha


Acquisition Editor: Rohit Rajkumar
Content Development Editor: Ron Mathew
Technical Editor: Prachi Sawant
Copy Editor: Safis Editing
Project Coordinator: Judie Jose
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Tom Scaria
Production Coordinator: Aparna Bhagat

First published: December 2015


Second edition: April 2018

Production reference: 1180418

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78899-055-4

www.packtpub.com
mapt.io

Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content


PacktPub.com
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.PacktPub.com and as a print book customer, you are
entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical


articles, sign up for a range of free newsletters, and receive
exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
Mokhtar Ebrahim started working as a Linux system administrator
in 2010. He is responsible for maintaining, securing, and
troubleshooting Linux servers for multiple clients around the world.
He loves writing shell and Python scripts to automate his work. He
writes technical articles on the Like Geeks website about Linux,
Python, web development, and server administration. He is a father
to a beautiful girl and a husband to a faithful wife.
I would like to thank my wife for helping me with all her efforts to finish this book. Thank you, Doaa, for being
a part of that. Also, I would like to thank everyone at Packt for working with me to make sure the book is
released. Last but not least, I'd like to thank Brian Fox, the author of the bash shell, for creating such an
awesome piece of software; without it, such a book would not exist.

Andrew Mallett is the owner of The Urban Penguin, and he is a


comprehensive provider of professional Linux software development,
training, and services. Having always been a command-line fan, he
feels that so much time can be saved through knowing command-
line shortcuts and scripting. TheUrbanPenguin YouTube channel,
maintained by Andrew, has well over 800 videos to support this, and
he has authored four other Packt titles.
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
About the reviewer
Sebastiaan Tammer is a Linux enthusiast from The Netherlands.
After attaining his BSc in Information Sciences, he graduated with
MSc in Business Informatics, both from Utrecht University. His
professional career started in Java development before he pivoted
into Linux.

He has worked on number of technologies, such as Puppet, Chef,


Docker, and Kubernetes. He spends a lot of time in and around his
terminal of choice: bash. Whether it is creating complex scripting
solutions or just automating simple tasks, there is hardly anything he
hasn't done with bash!
I would like to thank my girlfriend, Sanne, for all the help and support she has given me throughout the years.
She has had to endure the late nights studying, me fixing stuff (which I had inevitably broken only hours
earlier), and my endless storytelling about all those exciting new technologies. Thanks for the enormous
amount of patience and love, I could not have done it without you!
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit autho
rs.packtpub.com and apply today. We have worked with thousands of

developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are
recruiting an author for, or submit your own idea.
Table of Contents
Title Page

Copyright and Credits

Mastering Linux Shell Scripting Second Edition

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the authors

About the reviewer

Packt is searching for authors like you


Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

1. The What and Why of Scripting with Bash

Technical requirements

Types of Linux shells

What is bash scripting?

The bash command hierarchy


Command type

Command PATH

Preparing text editors for scripting

Configuring vim

Configuring nano

Configuring gedit

Creating and executing scripts


Hello World!

Executing the script

Checking the exit status

Ensuring a unique name

Hello Dolly!

Running the script with arguments

The importance of correct quotes

Printing the script name

Declaring variables

User-defined variables

Environment variables

Variable scope

Command substitution

Debugging your scripts

Summary

Questions

Further reading

2. Creating Interactive Scripts

Technical requirements

Using echo with options

Basic script using read

Script comments

Enhancing scripts with read prompts


Limiting the number of entered characters

Controlling the visibility of the entered text


Passing options

Passing parameters with options


Read options values

Try to be standard
Enhancing learning with simple scripts

Backing-up with scripts


Connecting to a server

Version 1 – ping


Version 2 – SSH

Version 3 – MySQL/MariaDB


Reading files
Summary
Questions

Further reading
3. Conditions Attached

Technical requirements
Simple decision paths using command-line lists

Verifying user input with lists


Using the test shell built-in

Testing strings
Testing integers

Testing file types


Creating conditional statements using if

Extending if with else


Test command with the if command

Checking strings
Checking files and directories

Checking numbers
Combining tests

More conditions with elif


Creating the backup2.sh using elif

Using case statements


Recipe – building a frontend with grep

Summary
Questions

Further reading
4. Creating Code Snippets

Technical requirements
Abbreviations

Using code snippets


Bringing color to the Terminal

Creating snippets using VS Code


Summary

Questions
Further reading

5. Alternative Syntax
Technical requirement
Recapping the test command
Testing files

Adding logic
Square brackets as not seen before

Providing parameter defaults


Variables
Special parameters

Setting defaults
When in doubt – quote!
Advanced tests using [[
White space

Other advanced features


Pattern matching
Regular expressions
Regular expression script

Arithmetic operations using ((


Simple math
Parameter manipulation
Standard arithmetic tests

Summary
Questions
Further reading
6. Iterating with Loops

Technical requirement
for loops
Advanced for loops
The IFS

Counting directories and files


C-style for loops 
Nested loops
Redirecting loop output

Controlling the loop


while loops and until loops
Reading input from files
Creating operator menus

Summary
Questions
Further reading
7. Creating Building Blocks with Functions

Technical requirements
Introducing functions
Passing parameters to functions

Passing arrays
Variable scope
Returning values from functions
Recursive functions

Using functions in menus


Summary
Questions
Further reading

8. Introducing the Stream Editor


Technical requirements
Using grep to display text
Displaying received data on an interface

Displaying user account data


Listing the number of CPUs in a system
Parsing CSV files
The CSV file

Isolating catalog entries


Understanding the basics of sed
The substitute command
Global replacement

Limiting substitution
Editing the file
Other sed commands
The delete command

The insert and append commands


The change command
The transform command
Multiple sed commands

Summary
Questions
Further reading
9. Automating Apache Virtual Hosts

Technical requirements
Apache name-based Virtual Hosts
Creating the virtual host template
First steps

Isolating lines
sed script files
Automating virtual host creation
Prompting for data during site creation

Summary
Questions
Further reading
10. AWK Fundamentals

Technical requirements
The history behind AWK
Displaying and filtering content from files
AWK variables

User-defined variables
Conditional statements
The if command
while loops

for loops
Formatting output
Further filtering to display users by UID
AWK control files

Built-in functions
Summary
Questions
Further reading

11. Regular Expressions


Technical requirements
Regular expression engines
Defining BRE patterns

Anchor characters
The dot character
The character class
Ranges of characters

Special character classes


The asterisk
Defining ERE patterns
The question mark

The plus sign


Curly braces
The pipe character
Expression grouping

Using grep
Summary

Questions

Further reading
12. Summarizing Logs with AWK

Technical requirements

The HTTPD log file format


Displaying data from web logs

Selecting entries by date


Summarizing 404 errors

Summarizing HTTP access codes

Resources hits
Identify image hotlinking

Displaying the highest ranking IP address

Displaying the browser data


Working with email logs

Summary
Questions

Further reading

13. A Better lastlog with AWK


Technical requirements

Using AWK ranges to exclude data

The lastlog command


Horizontally filtering rows with AWK

Counting matched rows


Conditions based on the number of fields
Manipulating the AWK record separator to report on XML data

Apache Virtual Hosts


XML catalog

Summary

Questions
Further reading

14. Using Python as a Bash Scripting Alternative


Technical requirements

What is Python?

Saying Hello World the Python way


Pythonic arguments

Supplying arguments

Counting arguments
Significant whitespace

Reading user input


Using Python to write to files

String manipulation

Summary
Questions

Further reading

Assessments
Chapter 1

Chapter 2
Chapter 3

Chapter 4

Chapter 5
Chapter 6

Chapter 7

Chapter 8
Chapter 9

Chapter 10

Chapter 11
Chapter 12

Chapter 13
Chapter 14

Other Books You May Enjoy


Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Leave a review - let other readers know what you think
Preface
First, you'll learn about Linux shells and why we chose the bash
shell. Then, you'll learn how to write a simple bash script and how to
edit your bash script using Linux editors.

Following this, you will learn how to define a variable and the
visibility of a variable. After this, you will learn how to store
command execution output into a variable, which is called command
substitution. Also, you will learn how to debug your code using bash
options and Visual Studio Code. You will learn how to make your
bash script interactive to the user by accepting input from the user
using the read command. Then, you will learn how to read options
and its values if the user passed them to the script. Following this,
you will learn how to write conditional statements such as if
statements and how to use case statements. After this, you will
learn how to create code snippets using vim and Visual Studio Code.
For repetitive tasks, you will see how to write for loops, how to
iterate over simple values, and how to iterate over directory content.
Also, you will learn how to write nested loops. Along with this, you
will write while and until loops. Then, we will move on to functions,
the reusable chunks of code. You will learn how to write functions
and how to use them. After this, you will be introduced to one of the
best tools in Linux, which is Stream Editor. As we are still talking
about text processing, we will introduce AWK, one of the best text
processing tools in Linux that you will ever see.

After this, you will learn how to empower your text processing skills
by writing better regular expressions. Finally, you will be introduced
to Python as an alternative to bash scripting.
Who this book is for
This book targets system administrators and developers who would
like to write a better shell script to automate their work. Some
programming experience is preferable. If you don't have any
background in shell scripting, no problem, the book will discuss
everything from the beginning.
What this book covers
, The What and Why of Scripting with Bash, will introduce
Chapter 1

Linux shells, how to write your first shell script, how to prepare your
editor, how to debug your shell script, and some basic bash
programming, such as declaring variables, variable scope, and
command substitution.

, Creating Interactive Scripts, covers how to read input from


Chapter 2

the user using read command, how to pass options to your script,
how to control the visibility of the entered text, and how to limit the
number of entered characters.

, Conditions Attached, will introduce the


Chapter 3 if statement, the case

statement, and other testing command such as else and elif.

, Creating Code Snippets, covers creating and using code


Chapter 4

snippets using editors, such as vim and Visual Studio Code.

, Alternative Syntax, will discuss advanced testing using


Chapter 5 [[

and how to perform arithmetic operations.

Chapter 6, Iterating with Loops, will teach you how to use for loops,
while loops, and until loops to iterate over simple values and complex

values.

, Creating Building Blocks with Functions, will introduce


Chapter 7

functions and explains how to create a function, list builtin functions,


pass parameters to functions, and writing recursive functions.

, Introducing the Stream Editor, will introduce the basics of


Chapter 8

sed tool to manipulate files, such as adding, replacing deleting, and


transforming text.
, Automating Apache Virtual Hosts, contains a practical
Chapter 9

example of sed and explains how to create virtual hosts


automatically using sed.

, AWK Fundamentals, will discuss AWK and how to filter file


Chapter 10

content using it. Also, we will discuss some AWK programming


basics.

, Regular Expressions, covers regular expressions, their


Chapter 11

engines, and how to use them with sed and AWK to empower your
script.

Chapter 12, Summarizing Logs with AWK, will show how to process the
httpd.conf Apache log file using AWK and extract useful well-formatted

data.

, A Better lastlog with AWK, will show you how to use AWK
Chapter 13

to output beautiful reports using the lastlog command by filtering


and processing the lastlog output.

, Using Python as a Bash Scripting Alternative, will discuss


Chapter 14

Python programming language basics and explains how to write


some Python scripts as a bash script alternative.
Random documents with unrelated
content Scribd suggests to you:
TO CLEAR VEGETABLES FROM INSECTS.

Lay them for half an hour or more into a pan of strong brine, with
the stalk ends uppermost; this will destroy the small snails and other
insects which cluster in the leaves, and they will fall out and sink to
the bottom. A pound and a half of salt to the gallon of water will
answer for this purpose, and if strained daily it will last for some time.
TO BOIL VEGETABLES GREEN.

After they have been properly prepared and washed, throw them
into plenty of boiling water which has been salted and well skimmed;
and keep them uncovered and boiling fast until they are done, taking
every precaution against their being smoked. Should the water be
very hard, a small half-teaspoonful of carbonate of soda, may be
added with the salt, for every two quarts, and will greatly improve the
colour of the vegetables; but if used in undue proportion it will injure
them; green peas especially will be quickly reduced to a mash if
boiled with too large a quantity.
Water, 1 gallon; salt, 2 oz.; soda, 1/4 oz.; or carbonate of soda, 1
teaspoonful.
POTATOES.

(Remarks on their properties and importance.)


There is no vegetable commonly cultivated in this country, we
venture to assert, which is comparable in value to the potato when it
is of a good sort, has been grown in a suitable soil, and is properly
cooked and served. It must be very nutritious, or it would not sustain
the strength of thousands of people whose almost sole food it
constitutes, and who, when they can procure a sufficient supply of it
to satisfy fully the demands of hunger, are capable of accomplishing
the heaviest daily labour. It may not be wise to depend for
subsistence on a root of which the crop unhappily is so frequently in
these days destroyed or greatly injured by disease, and for which it
is so difficult to find a substitute that is equally cheap, wholesome
and satisfying; but we can easily comprehend the predilection of an
entire people for a tuber which combines, like the potato, the solidity
almost of bread, with the healthful properties[103] of various other
fresh vegetables, without their acidity; and which can also be cooked
and served in so many different forms. The wretched manner in
which it is dressed in many English houses renders it comparatively
valueless, and accounts in a measure for the prodigality with which it
is thrown away when cold, even in seasons when its price is highest.
[104]
103. The late Dr. Pereira has stated in his excellent work on diet, page 370, that
Dr. Baly, who has published some interesting observations on the anti-
scorbutic quality of the potato, says, “As ordinarily cooked, it is an admirable
preservative against the scurvy,” for which it appears to be also a cure, see
the same work.

104. We cannot refrain from a few words of remark here on the daily waste of
wholesome food in this country which constitutes one of the most serious
domestic abuses that exist amongst us; and one which it is most painful to
witness while we see at the same time the half-starvation of large masses of
our people. It is an evil which the steady and resolute opposition of the
educated classes would soon greatly check; and which ought not vainly to
appeal to their good sense and good feeling, augmenting, as it must, the
privations of the scantily-fed poor; for the “waste” of one part of the
community cannot fail to increase the “want” of the remainder.
TO BOIL POTATOES.

(As in Ireland.)
Potatoes, to boil well together, should be all of the same sort, and
as nearly equal in size as may be. Wash off the mould, and scrub
them very clean with a hard brush, but neither scoop nor apply a
knife to them in any way, even to clear the eyes.[105] Rinse them
well, and arrange them compactly in a saucepan, so that they may
not lie loose in the water, and that a small quantity may suffice to
cover them. Pour this in cold, and when it boils, throw in about a
large teaspoonful of salt to the quart, and simmer the potatoes until
they are nearly done, but for the last two or three minutes let them
boil rapidly. When they are tender quite through, which may be
known by probing them with a fork, pour all the water from them
immediately, lift the lid of the saucepan to allow the steam to escape,
and place them on a trivet, high over the fire, or by the side of it, until
the moisture has entirely evaporated; then peel, and send them to
table as quickly as possible, either in a hot napkin, or in a dish, of
which the cover is so placed that the steam can pass off. There
should be no delay in serving them after they are once taken from
the fire. Irish families always prefer them served in their skins. Some
kinds will be sufficiently boiled in twenty minutes, others in not less
than three quarters of an hour.
105. “Because,” in the words of our clever Irish correspondent, “the water through
these parts is then admitted into the very heart of the vegetable; and the
latent heat, after cooking, is not sufficient to throw it off; this renders the
potatoes very unwholesome.”

20 minutes to 1 hour, or more.


Obs. 1.—The water in which they are boiled should barely cover
the potatoes. After it is poured off, they should be steamed for twenty
minutes or half an hour, if large.
Obs. 2.—Habitual potato-eaters know well that this vegetable is
never so good as when served in the skin the instant it is taken from
the fire, dished in a hot napkin, or sent to table without a cover over
it. It should also be clean and dry that it may at pleasure be taken in
the fingers and broken like bread, or held in the dinner napkin while
the inside is scooped out with the fork, thus forming it into a sort of
cup. The large Yorkshire Regents dressed and eaten in this way
afford in themselves an almost sufficient meal. We have found from
long daily experience, that those which averaged three, or at the
utmost four to the pound, were the best in quality, and remained so
to quite the end of their season: they required as the spring
advanced, an hour’s boiling or more.
TO BOIL POTATOES.

(The Lancashire way.)


Pare the potatoes, cover them with cold water, and boil them
slowly until they are quite tender, but watch them carefully, that they
may not be overdone; drain off the water entirely, strew some salt
over them, leave the saucepan uncovered by the side of the fire, and
shake it forcibly every minute or two, until the whole of the potatoes
appear dry and floury. Lancashire cooks dress the vegetable in this
way to perfection, but it is far from an economical mode, as a large
portion of the potato adheres to the saucepan; it has, however, many
admirers.
TO BOIL NEW POTATOES.

These are never good unless freshly dug. Take them of equal size,
and rub off the skins with a brush or a very coarse cloth, wash them
clean, and put them without salt into boiling, or at least, quite hot
water; boil them softly, and when they are tender enough to serve,
pour off the water entirely, strew some fine salt over them, give them
a shake, and let them stand by the fire in the saucepan for a minute;
then dish and serve them immediately. Some cooks throw in a small
slice of fresh butter, with the salt, and toss them gently in it after it is
dissolved. This is a good mode, but the more usual one is to send
melted butter to table with them, or to pour white sauce over them
when they are very young, and served early in the season.
Very small, 10 to 15 minutes: moderate sized, 15 to 20 minutes.
Obs.—We always, for our own eating, have new potatoes
steamed for ten minutes or longer after the water is poured from
them, and think they are much improved by the process. They
should be thoroughly boiled before this is done.
NEW POTATOES IN BUTTER.

Rub off the skins, wash the potatoes well and wipe them dry; put
them with three ounces of good butter, for a small dish, and with four
ounces or more for a large one, into a well-tinned stewpan or Keep
them well shaken or tossed, that they may be equally done, and
throw in some salt when they begin to stew. This is a good mode of
dressing them when they are very young and watery.
TO BOIL POTATOES.

(Captain Kater’s Receipt.)


Wash, wipe, and pare the potatoes, cover them with cold water,
and boil them gently until they are done, pour off the water, and
sprinkle a little fine salt over them; then take each potato separately
with a spoon, and lay it into a clean warm cloth, twist this so as to
press all the moisture from the vegetable, and render it quite round;
turn it carefully into a dish placed before the fire, throw a cloth over,
and when all are done, send them to table quickly. Potatoes dressed
in this way are mashed without the slightest trouble; it is also by far
the best method of preparing them for puddings or for cakes.
TO ROAST OR BAKE POTATOES.

Scrub and wash exceedingly clean some potatoes nearly assorted


in size; wipe them very dry, and roast them in a Dutch oven before
the fire, placing them at a distance from it, and keeping them often
turned; or arrange them in a coarse dish, and bake them in a
moderate oven. Dish them neatly in a napkin, and send them very
hot to table; serve cold butter with them. 1-3/4 to upwards of 2 hours.
SCOOPED POTATOES. (ENTREMETS.[106])

106. Or second course dish.

Wash and wipe some large


potatoes of a firm kind, and with
a small scoop adapted to the
purpose,[107] form as many
diminutive ones as will fill a dish;
cover them with cold water, and when they have boiled very gently
for five minutes pour it off, and put more cold water to them; after
they have simmered a second time for five minutes, drain the water
quite away, place the cover of the saucepan so as to leave an inch
or more of open space for the moisture to evaporate, and let them
steam by the side of the fire from four to five minutes longer. Dish
them carefully, pour white sauce over them, and serve them in the
second course. Old potatoes thus prepared, have often been made
to pass for new ones, at the best tables, at the season in which the
fresh vegetable was dearest.[108] The time required to boil them will
of course vary with their quality; we give the method which we have
found very successful.
107. This may be procured of any ironmonger.

108. Vegetables and fruit are now so generally forced and brought so early into
our markets, that there is little need of these expedients at present.
CRISPED POTATOES, OR POTATO-RIBBONS. (ENTREMETS.)

(Or to serve with Cheese.)


Wash well, and wipe, some potatoes of good flavour; cut them up
into slices of from half to a whole inch thick, free them from the skins,
and then pare them round and round in very thin, and very long
ribbons. Lay them into a pan of cold water, and half an hour before
they are wanted for table lift them on to a sieve that they may be well
drained. Fry them in good butter, which should be very hot when
they are thrown in, until they are quite crisp, and lightly browned;
drain and dry them on a soft cloth, pile them in a hot dish, strew over
them a mixed seasoning of salt and cayenne in fine powder, and
serve them without delay. For the second course, dress them in the
same manner, but omit the cayenne. Five or six minutes will fry
them.
FRIED POTATOES. (ENTREMETS.)

(A Plainer Receipt.)
After having washed them, wipe and pare some raw potatoes, cut
them in slices of equal thickness, or into thin shavings, and throw
them into plenty of boiling butter, or very pure clarified dripping. Fry
them of a fine light brown, and very crisp; lift them out with a
skimmer, drain them on a soft warm cloth, dish them very hot, and
sprinkle fine salt over them. This is an admirable way of dressing
potatoes, very common on the Continent, but less so in England
than it deserves to be. Pared in ribbons or shavings of equal width,
as in the receipt above, and served dry and well fried, lightly piled in
a dish, they make a handsome appearance, and are excellent
eating. If sliced they should be something less than a quarter of an
inch thick.
MASHED POTATOES.

Boil them perfectly tender quite through, pour off the water, and
steam them very dry by the directions already given in the receipt of
page 310, peel them quickly, take out every speck, and while they
are still hot, press the potatoes through an earthen cullender, or
bruise them to a smooth mash with a strong wooden fork or spoon,
but never pound them in a mortar, as that will reduce them to a close
heavy paste. Let them be entirely free from lumps, for nothing can be
more indicative of carelessness or want of skill on the part of the
cook, than mashed potatoes sent to table full of these. Melt in a
clean saucepan a slice of good butter with a few spoonsful of milk,
or, better still, of cream; put in the potatoes after having sprinkled
some fine salt upon them, and stir the whole over a gentle fire with a
wooden spoon, until the ingredients are well-mixed, and the whole is
very hot. It may then be served directly; or heaped high in a dish, left
rough on the surface, and browned before the fire; or it may be
pressed into a well buttered mould of handsome form, which has
been strewed with the finest bread-crumbs, and shaken free from the
loose ones, then turned out, and browned in a Dutch or common
oven. More or less liquid will be required to moisten sufficiently
potatoes of various kinds.
Potatoes mashed, 2 lbs.; salt, 1 teaspoonful; butter, 1 to 2 oz.; milk
or cream, 1/4 pint.
Obs.—Mashed potatoes are often moulded with a cup, and then
equally browned: any other shape will answer the purpose as well,
and many are of better appearance.

ENGLISH POTATO BALLS, OR CROQUETTES.

Boil some floury potatoes very dry, mash them as smoothly as


possible, season them well with salt and white pepper, warm them
with about an ounce of butter to the pound, or rather more if it will not
render them too moist, and a few spoonsful of good cream. Boil
them very dry; let them cool a little, roll them into balls, sprinkle over
them vermicelli crushed slightly with the hand, and fry them a fine
light brown. They may be dished round a shape of plain mashed
potatoes, or piled on a napkin by themselves. They may likewise be
rolled in egg and fine bread-crumbs instead of in the vermicelli, or in
ground rice, which answers very well for them.
POTATO BOULETTES. (ENTREMETS.)

(Good.)
Boil some good potatoes as dry as possible, or let them be
prepared by Captain Kater’s receipt; mash a pound of them very
smoothly, and mix with them while they are still warm, two ounces of
fresh butter, a teaspoonful of salt, a little nutmeg, the beaten and
strained yolks of four eggs, and last of all the whites thoroughly
whisked. Mould the mixture with a teaspoon and drop it into a small
pan of boiling butter, or of very pure lard, and fry the boulettes for
five minutes over a moderate fire: they should be of a fine pale
brown, and very light. Drain them well and dish them on a hot
napkin.
Potatoes, 1 lb.; butter, 2 oz.; salt, 1 teaspoonful; eggs, 4: 5
minutes.
Obs.—These boulettes are exceeding light and delicate, and make
an excellent dish for the second course; but we think that a few
spoonsful of sweet fresh cream boiled with them until the mixture
becomes dry, would both enrich them and improve their flavour. They
should be dropped into the pan with the teaspoon, as they ought to
be small, and they will swell in the cooking.
POTATO RISSOLES.

(French.)
Mash and season the potatoes with salt, and white pepper or
cayenne, and mix with them plenty of minced parsley, and a small
quantity of green onions, or eschalots; add sufficient yolks of eggs to
bind the mixture together, roll it into small balls, and fry them in
plenty of lard or butter over a moderate fire, or they will be too much
browned before they are done through. Ham, or any other kind of
meat finely minced, may be substituted for the herbs, or added to
them.
POTATOES À LA MAÎTRE D’HÔTEL.

Boil in the usual manner some potatoes of a firm kind, peel, and
let them cool; then cut them equally into quarter-inch slices. Dissolve
in a very clean stewpan or saucepan from two to four ounces of
good butter, stir to it a small dessertspoonful of flour, and shake the
pan over the fire for two or three minutes; add by slow degrees a
small cupful of boiling water, some pepper, salt, and a tablespoonful
of minced parsley; put in the potatoes, and toss them gently over a
clear fire until they are quite hot, and the sauce adheres well to
them: at the instant of serving add a dessertspoonful of strained
lemon-juice. Pale veal gravy may be substituted for the water; and
the potatoes after being thickly sliced, may be quickly cut of the
same size with a small round cutter.
POTATOES À LA CRÈME.

Prepare the potatoes as above, and toss them gently in a quarter


of a pint or more of thick white sauce or of common bechamel, with
or without the addition of the minced parsley.

You might also like