100% found this document useful (8 votes)
54 views

Where can buy Learning the bash Shell Unix Shell Programming Third Edition Cameron Newham ebook with cheap price

Programming

Uploaded by

boteozaikaws
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
54 views

Where can buy Learning the bash Shell Unix Shell Programming Third Edition Cameron Newham ebook with cheap price

Programming

Uploaded by

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

Download the full version of the ebook at ebookfinal.

com

Learning the bash Shell Unix Shell Programming


Third Edition Cameron Newham

https://ebookfinal.com/download/learning-the-bash-shell-
unix-shell-programming-third-edition-cameron-newham/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookfinal.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Pro Bash Programming Second Edition Scripting the GNU


Linux Shell Johnson

https://ebookfinal.com/download/pro-bash-programming-second-edition-
scripting-the-gnu-linux-shell-johnson/

ebookfinal.com

Learning Unix for OS X Going Deep With the Terminal and


Shell 2nd Edition Dave Taylor

https://ebookfinal.com/download/learning-unix-for-os-x-going-deep-
with-the-terminal-and-shell-2nd-edition-dave-taylor/

ebookfinal.com

Ghost in the Shell 2nd Edition Masamune Shirow

https://ebookfinal.com/download/ghost-in-the-shell-2nd-edition-
masamune-shirow/

ebookfinal.com

Kant s Observations and Remarks A Critical Guide Shell

https://ebookfinal.com/download/kant-s-observations-and-remarks-a-
critical-guide-shell/

ebookfinal.com
SSH The Secure Shell The Definitive Guide 1st Edition
Daniel J. Barrett

https://ebookfinal.com/download/ssh-the-secure-shell-the-definitive-
guide-1st-edition-daniel-j-barrett/

ebookfinal.com

SSH The Secure Shell The Definitive Guide Second Edition


Daniel J. Barrett

https://ebookfinal.com/download/ssh-the-secure-shell-the-definitive-
guide-second-edition-daniel-j-barrett/

ebookfinal.com

Harnessing the UEFI Shell Moving the Platform Beyond DOS


Second Edition Michael Rothman

https://ebookfinal.com/download/harnessing-the-uefi-shell-moving-the-
platform-beyond-dos-second-edition-michael-rothman/

ebookfinal.com

Linux Command Line and Shell Scripting Bible 2nd Edition


Richard Blum

https://ebookfinal.com/download/linux-command-line-and-shell-
scripting-bible-2nd-edition-richard-blum/

ebookfinal.com

Oral culture and Catholicism in early modern England 1st


Edition Alison Shell

https://ebookfinal.com/download/oral-culture-and-catholicism-in-early-
modern-england-1st-edition-alison-shell/

ebookfinal.com
1
Learning the bash Shell,
3rd Edition
Table of Contents

2
Preface
bash Versions
Summary of bash Features
Intended Audience
Code Examples
Chapter Summary
Conventions Used in This Handbook
We'd Like to Hear from You
Using Code Examples
Safari Enabled
Acknowledgments for the First Edition
Acknowledgments for the Second Edition
Acknowledgments for the Third Edition

1. bash Basics

3
1.1. What Is a Shell?
1.2. Scope of This Book
1.3. History of UNIX Shells
1.3.1. The Bourne Again Shell
1.3.2. Features of bash

1.4. Getting bash


1.5. Interactive Shell Use
1.5.1. Commands, Arguments, and Options

1.6. Files
1.6.1. Directories
1.6.2. Filenames, Wildcards, and Pathname
Expansion
1.6.3. Brace Expansion

1.7. Input and Output


1.7.1. Standard I/O
1.7.2. I/O Redirection
1.7.3. Pipelines

1.8. Background Jobs


1.8.1. Background I/O
1.8.2. Background Jobs and Priorities

1.9. Special Characters and Quoting


1.9.1. Quoting
1.9.2. Backslash-Escaping
1.9.3. Quoting Quotation Marks
1.9.4. Continuing Lines
1.9.5. Control Keys

4
1.10. Help

2. Command-Line Editing
2.1. Enabling Command-Line Editing
2.2. The History List
2.3. emacs Editing Mode
2.3.1. Basic Commands
2.3.2. Word Commands
2.3.3. Line Commands
2.3.4. Moving Around in the History List
2.3.5. Textual Completion
2.3.6. Miscellaneous Commands

2.4. vi Editing Mode


2.4.1. Simple Control Mode Commands
2.4.2. Entering and Changing Text
2.4.3. Deletion Commands
2.4.4. Moving Around in the History List
2.4.5. Character-Finding Commands
2.4.6. Textual Completion
2.4.7. Miscellaneous Commands

2.5. The fc Command


2.6. History Expansion
2.7. readline
2.7.1. The readline Startup File
2.7.2. Key Bindings Using bind

2.8. Keyboard Habits

3. Customizing Your Environment

5
3.1. The .bash_profile, .bash_logout, and .bashrc
Files
3.2. Aliases
3.3. Options
3.3.1. shopt

3.4. Shell Variables


3.4.1. Variables and Quoting
3.4.2. Built-In Variables

3.5. Customization and Subprocesses


3.5.1. Environment Variables
3.5.2. The Environment File

3.6. Customization Hints

4. Basic Shell Programming

6
4.1. Shell Scripts and Functions
4.1.1. Functions

4.2. Shell Variables


4.2.1. Positional Parameters
4.2.2. Local Variables in Functions
4.2.3. Quoting with $@ and $*
4.2.4. More on Variable Syntax

4.3. String Operators


4.3.1. Syntax of String Operators
4.3.2. Patterns and Pattern Matching
4.3.3. Length Operator
4.3.4. Extended Pattern Matching

4.4. Command Substitution


4.5. Advanced Examples: pushd and popd

5. Flow Control
5.1. if/else
5.1.1. Exit Status
5.1.2. Return
5.1.3. Combinations of Exit Statuses
5.1.4. Condition Tests
5.1.5. Integer Conditionals

5.2. for
5.3. case
5.4. select
5.5. while and until

6. Command-Line Options and Typed Variables

7
6.1. Command-Line Options
6.1.1. shift
6.1.2. Options with Arguments
6.1.3. getopts

6.2. Typed Variables


6.3. Integer Variables and Arithmetic
6.3.1. Arithmetic Conditionals
6.3.2. Arithmetic Variables and Assignment
6.3.3. Arithmetic for Loops

6.4. Arrays

7. Input/Output and Command-Line Processing


7.1. I/O Redirectors
7.1.1. Here-documents
7.1.2. File Descriptors

7.2. String I/O


7.2.1. echo
7.2.2. printf
7.2.3. read

7.3. Command-Line Processing


7.3.1. Quoting
7.3.2. command, builtin, and enable
7.3.3. eval

8. Process Handling

8
8.1. Process IDs and Job Numbers
8.2. Job Control
8.2.1. Foreground and Background
8.2.2. Suspending a Job

8.3. Signals
8.3.1. Control-Key Signals
8.3.2. kill
8.3.3. ps

8.4. trap
8.4.1. Traps and Functions
8.4.2. Process ID Variables and Temporary
Files
8.4.3. Ignoring Signals
8.4.4. disown
8.4.5. Resetting Traps

8.5. Coroutines
8.5.1. wait
8.5.2. Advantages and Disadvantages of
Coroutines
8.5.3. Parallelization

8.6. Subshells
8.6.1. Subshell Inheritance
8.6.2. Nested Subshells

8.7. Process Substitution

9. Debugging Shell Programs

9
9.1. Basic Debugging Aids
9.1.1. Set Options
9.1.2. Fake Signals
9.1.3. Debugging Variables

9.2. A bash Debugger


9.2.1. Structure of the Debugger
9.2.2. The Preamble
9.2.3. Debugger Functions
9.2.4. A Sample bashdb Session
9.2.5. Exercises

10. bash Administration


10.1. Installing bash as the Standard Shell
10.1.1. POSIX Mode
10.1.2. Command-Line Options

10.2. Environment Customization


10.2.1. umask
10.2.2. ulimit
10.2.3. Types of Global Customization

10.3. System Security Features


10.3.1. Restricted Shell
10.3.2. A System Break-In Scenario
10.3.3. Privileged Mode

11. Shell Scripting

10
11.1. What's That Do?
11.1.1. Comments
11.1.2. Variables and Constants

11.2. Starting Up
11.3. Potential Problems
11.4. Don't Use bash

12. bash for Your System


12.1. Obtaining bash
12.2. Unpacking the Archive
12.3. What's in the Archive
12.3.1. Documentation
12.3.2. Configuring and Building bash
12.3.3. Testing bash
12.3.4. Potential Problems
12.3.5. Installing bash as a Login Shell
12.3.6. Examples

12.4. Who Do I Turn to?


12.4.1. Asking Questions
12.4.2. Reporting Bugs

A. Related Shells

11
A.1. The Bourne Shell
A.2. The IEEE 1003.2 POSIX Shell Standard
A.3. The Korn Shell
A.4. pdksh
A.5. zsh
A.6. Shell Clones and Unix-like Platforms
A.6.1. Cygwin
A.6.2. DJGPP
A.6.3. MKS Toolkit
A.6.4. AT&T UWIN

B. Reference Lists
B.1. Invocation
B.2. Prompt String Customizations
B.3. Built-In Commands and Reserved Words
B.4. Built-In Shell Variables
B.5. Test Operators
B.6. set Options
B.7. shopt Options
B.8. I/O Redirection
B.9. emacs Mode Commands
B.10. vi Control Mode Commands

C. Loadable Built-Ins
D. Programmable Completion

12
Learning the bash Shell,
3rd Edition
Cameron Newham
Copyright © 2009 O'Reilly Media, Inc.

O'Reilly Media, Inc.

13
Preface
The first thing users of the UNIX or Linux operating
systems come face to face with is the shell. "Shell" is the
UNIX term for a user interface to the system—something
that lets you communicate with the computer via the
keyboard and the display. Shells are just separate
programs that encapsulate the system, and, as such, there
are many to choose from.

Systems are usually set up with a "standard" shell that


new users adopt without question. However, some of
these standard shells are rather old and lack many
features of the newer shells. This is a shame, because
shells have a large bearing on your working environment.
Since changing shells is as easy as changing hats, there is
no reason not to change to the latest and greatest in shell
technology.

Of the many shells to choose from, this book introduces


the Bourne Again shell (bash for short), a modern
general-purpose shell. Other useful modern shells are the
Korn shell (ksh) and the "Tenex C shell" (tcsh); both are
also the subjects of O'Reilly handbooks.

14
bash Versions
This book is relevant to all versions of bash, although
older versions lack some of the features of the most
recent version.[1] You can easily find out which version
you are using by typing echo $BASH_VERSION. The
earliest public version of bash was 1.0, and the most
recent is 3.0 (released in July 2004). If you have an older
version, you might like to upgrade to the latest one.
Chapter 12 shows you how to go about it.

[1]
Throughout this book we have clearly marked with
footnotes the features that are not present in the earlier
versions.

15
Summary of bash
Features
bash is a backward-compatible evolutionary successor to
the Bourne shell that includes most of the C shell's major
advantages as well as features from the Korn shell and a
few new features of its own. Features appropriated from
the C shell include:

• Directory manipulation, with the pushd, popd,


and dirs commands.

• Job control, including the fg and bg commands


and the ability to stop jobs with CTRL-Z.

• Brace expansion, for generating arbitrary strings.

• Tilde expansion, a shorthand way to refer to


directories.

• Aliases, which allow you to define shorthand


names for commands or command lines.

• Command history, which lets you recall


previously entered commands.

bash's major new features include:

16
• Command-line editing, allowing you to use vi- or
emacs-style editing commands on your command
lines.

• Key bindings that allow you to set up customized


editing key sequences.

• Integrated programming features: the


functionality of several external UNIX
commands, including test, expr, getopt, and echo,
has been integrated into the shell itself, enabling
common programming tasks to be done more
cleanly and efficiently.

• Control structures, especially the select construct,


which enables easy menu generation.

• New options and variables that give you more


ways to customize your environment.

• One dimensional arrays that allow easy


referencing and manipulation of lists of data.

• Dynamic loading of built-ins, plus the ability to


write your own and load them into the running
shell.

17
Intended Audience
This book is designed to address casual UNIX and Linux
users who are just above the "raw beginner" level. You
should be familiar with the process of logging in, entering
commands, and doing simple things with files. Although
Chapter 1 reviews concepts such as the tree-like file and
directory scheme, you may find that it moves too quickly
if you're a complete neophyte. In that case, we
recommend the O'Reilly handbook, Learning the UNIX
Operating System, by Jerry Peek, Grace Todino, and John
Strang.

If you're an experienced user, you may wish to skip


Chapter 1 altogether. But if your experience is with the C
shell, you may find that Chapter 1 reveals a few subtle
differences between the bash and C shells.

No matter what your level of experience is, you will


undoubtedly learn many things in this book that will
make you a more productive bash user—from major
features down to details at the "nook-and-cranny" level
that you may not have been aware of.

If you are interested in shell programming (writing shell


scripts and functions that automate everyday tasks or
serve as system utilities), you should also find this book
useful. However, we have deliberately avoided drawing a
strong distinction between interactive shell use (entering

18
commands during a login session) and shell
programming. We see shell programming as a natural,
inevitable outgrowth of increasing experience as a user.

Accordingly, each chapter depends on those previous to


it, and although the first three chapters are oriented
toward interactive use only, subsequent chapters describe
interactive, user-oriented features in addition to
programming concepts.

This book aims to show you that writing useful shell


programs doesn't require a computing degree. Even if you
are completely new to computing, there is no reason why
you shouldn't be able to harness the power of bash within
a short time.

Toward that end, we decided not to spend too much time


on features of exclusive interest to low-level systems
programmers. Concepts like file descriptors and special
file types might only confuse the casual user, and
anyway, we figure those of you who understand such
things are smart enough to extrapolate the necessary
information from our cursory discussions.

19
Code Examples
This book is full of examples of shell commands and
programs designed to be useful in your everyday life as a
user, not just to illustrate the feature being explained. In
Chapter 4 and onwards, we include various programming
problems, which we call tasks, that illustrate particular
shell programming concepts. Some tasks have solutions
that are refined in subsequent chapters. The later chapters
also include programming exercises, many of which build
on the tasks in the chapter.

Feel free to use any code you see in this book and to pass
it along to friends and colleagues. We especially
encourage you to modify and enhance it yourself.

If you want to try examples but you don't use bash as


your login shell, you must put the following line at the
top of each shell script:

#!/bin/bash

If bash isn't installed as the file /bin/bash, substitute its


pathname in the above.

20
Chapter Summary
If you want to investigate specific topics rather than read
the entire book through, here is a chapter-by-chapter
summary:

Chapter 1 introduces bash and tells you how to install it


as your login shell. Then it surveys the basics of
interactive shell use, including overviews of the UNIX
file and directory scheme, standard I/O, and background
jobs.

Chapter 2 discusses the shell's command history


mechanism (including the emacs- and vi-editing modes),
history substitution and the fc history command, and key
bindings with readline and bind.

Chapter 3 covers ways to customize your shell


environment without programming by using the startup
and environment files. Aliases, options, and shell
variables are the customization techniques discussed.

Chapter 4 is an introduction to shell programming. It


explains the basics of shell scripts and functions, and
discusses several important "nuts-and-bolts"
programming features: string manipulation operators,
brace expansion, command-line arguments (positional
parameters), and command substitution.

21
Chapter 5 continues the discussion of shell programming
by describing command exit status, conditional
expressions, and the shell's flow-control structures: if,
for, case, select, while, and until.

Chapter 6 goes into depth about positional parameters and


command-line option processing, then discusses special
types and properties of variables, integer arithmetic, and
arrays.

Chapter 7 gives a detailed description of bash I/O. This


chapter covers all of the shell's I/O redirectors, as well as
the line-at-a-time I/O commands read and echo. It also
discusses the shell's command-line processing mechanism
and the eval command.

Chapter 8 covers process-related issues in detail. It starts


with a discussion of job control, then gets into various
low-level information about processes, including process
IDs, signals, and traps. The chapter then moves to a
higher level of abstraction to discuss coroutines and
subshells.

Chapter 9 discusses various debugging techniques, like


trace and verbose modes, and the "fake" signal traps. It
then presents in detail a useful shell tool, written using
the shell itself: a bash debugger.

Chapter 10 gives information for system administrators,


including techniques for implementing system-wide shell
customization and features related to system security.

22
Chapter 11 discusses ways to make bash scripts more
maintainable.

Chapter 12 shows you how to go about getting bash and


how to install it on your system. It also outlines what to
do in the event of problems along the way.

Appendix A compares bash to several similar shells,


including the standard Bourne shell, the POSIX shell
standard, the Korn shell (ksh), the public-domain Korn
shell (pdksh), and the Z Shell (zsh).

Appendix B contains lists of shell invocation options,


built-in commands, built-in variables, conditional test
operators, options, I/O redirection, and emacs- and
vi-editing mode commands.

Appendix C gives information on writing and compiling


your own loadable built-ins.

Appendix D looks at the basics of programmable


completion.

23
Conventions Used in
This Handbook
We leave it as understood that when you enter a shell
command, you press RETURN at the end. RETURN is
labeled ENTER on some keyboards.

Characters called CTRL-X, where X is any letter, are


entered by holding down the CTRL (or CTL, or
CONTROL) key and pressing that letter. Although we
give the letter in uppercase, you can press the letter
without the SHIFT key.

Other special characters are LINEFEED (which is the


same as CTRL-J), BACKSPACE (same as CTRL-H),
ESC, TAB, and DEL (sometimes labeled DELETE or
RUBOUT).

This book uses the following font conventions:

Italic
Used for UNIX filenames, commands not built into
the shell (which are files anyway), and shell
functions. Italic is also used for dummy parameters
that should be replaced with an actual value, to
distinguish the vi and emacs programs from their
bash modes, and to highlight special terms the first
time they are defined.

24
Bold
Used for bash built-in commands, aliases, variables,
and options, as well as command lines when they are
within regular text. Bold is used for all elements
typed in by the user within regular text.

Constant Width
Used in examples to show the contents of files or the
output from commands.

Constant Bold
Used in examples to show interaction between the
user and the shell; any text the user types in is shown
in Constant Bold. For example:$ pwd/home/
cam/adventure/carrol $

Constant Italic
Used in displayed command lines for dummy
parameters that should be replaced with an actual
value.

Square Brackets
Used in Chapter 2 to show the position of the cursor
on the command line being edited. For
example:grep -l Alice < ~cam/book/
[a]iw

25
We use UNIX as a shorthand for "UNIX and Linux."
Purists will correctly insist that Linux is not
UNIX—but as far as this book is concerned, they
behave identically.

26
We'd Like to Hear from
You
Please address comments and questions concerning this
book to the publisher:

O'Reilly Media, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)
We have a web page for this book, where we list errata,
examples, and any additional information. You can
access this page at:

http://www.oreilly.com/catalog/bash3
To comment or ask technical questions about this book,
send email to:

[email protected]
For more information about our books, conferences,
Resource Centers, and the O'Reilly Network, see our web
site at:

http://www.oreilly.com

27
Using Code Examples
This book is here to help you get your job done. In
general, you may use the code in this book in your
programs and documentation. You do not need to contact
us for permission unless you're reproducing a significant
portion of the code. For example, writing a program that
uses several chunks of code from this book does not
require permission. Selling or distributing a CD-ROM of
examples from O'Reilly books does require permission.
Answering a question by citing this book and quoting
example code does not require permission. Incorporating
a significant amount of example code from this book into
your product's documentation does require permission.

We appreciate, but do not require, attribution. An


attribution usually includes the title, author, publisher,
and ISBN. For example "Learning the bash Shell, Third
Edition, by Cameron Newham and Bill Rosenblatt.
Copyright 2005 O'Reilly Media, Inc., 0-596-00965-8."

28
Safari Enabled

When you see a Safari® Enabled icon on the cover of


your favorite technology book, that means the book is
available online through the O'Reilly Network Safari
Bookshelf.

Safari offers a solution that's better than e-books. It's a


virtual library that lets you easily search thousands of top
tech books, cut and paste code samples, download
chapters, and find quick answers when you need the most
accurate, current information. Try it for free at
http://safari.oreilly.com.

29
Acknowledgments for
the First Edition
This project has been an interesting experience and
wouldn't have been possible without the help of a number
of people. Firstly, I'd like to thank Brian Fox and Chet
Ramey for creating bash and making it the polished
product it is today. Thanks also to Chet Ramey for
promptly answering all of my questions on bash and
pointing out my errors.

Many thanks to Bill Rosenblatt for Learning the korn


Shell, on which this book is based; Michael O'Reilly and
Michael Malone at iiNet Technologies for their useful
comments and suggestions (and my net.connection!);
Chris Thorne, Justin Twiss, David Quin-Conroy, and my
mum for their comments, suggestions, and corrections;
Linus Torvalds for the Linux operating system which
introduced me to bash and was the platform for all of my
work on the book; Brian Fox for providing a short history
of bash; David Korn for information on the latest Korn
shell. Thanks also to Depeche Mode for "101" as a
backdrop while I worked, Laurence Durbridge for being a
likable pest and never failing to ask "Finished the book
yet?" and Adam (for being in my book).

The sharp eyes of our technical reviewers picked up


many mistakes. Thanks to Matt Healy, Chet Ramey, Bill

30
Reynolds, Bill Rosenblatt, and Norm Walsh for taking
time out to go through the manuscript.

The crew at O'Reilly were indispensable in getting this


book out the door. I'd like to thank Lenny Muellner for
providing me with the formatting tools for the job, Chris
Reilley for the figures, and Edie Freedman for the cover
design. On the production end, I'd like to thank David
Sewell for his copyediting, Clairemarie Fisher O'Leary
for managing the production process, Michael Deutsch
and Jane Ellin for their production assistance, Ellen
Siever for tools support, Kismet McDonough for
providing quality assurance, and Seth Maislin for the
index.

I'm grateful to Frank Willison for taking me up on my


first piece of email to ORA: "What about a book on
bash?"

Last but by no means least, a big thank you to my editor,


Mike Loukides, who helped steer me through this project.

31
Acknowledgments for
the Second Edition
Thanks to all the people at O'Reilly. Gigi Estabrook was
the editor for the second edition. Nicole Gipson Arigo
was the production editor and project manager. Nancy
Wolfe Kotary and Ellie Fountain Maden performed
quality control checks. Seth Maislin wrote the index. Edie
Freedman designed the cover, and Nancy Priest designed
the interior format of the book. Lenny Muellner
implemented the format in troff. Robert Romano updated
the illustrations for the second edition.

32
Acknowledgments for
the Third Edition
Thanks to the production people at O'Reilly and to the
indexer.

Thanks to Chet Ramey for once again swiftly answering


my queries on bash and for providing helpful comments
on the book. I'd also like to thank Ian Macdonald for his
feedback on Programmable Completion.

33
Chapter 1. bash Basics
Since the early 1970s, when it was first created, the
UNIX operating system has become more and more
popular. During this time it has branched out into
different versions, and taken on such names as Ultrix,
AIX, Xenix, SunOS, and Linux. Starting on
minicomputers and mainframes, it has moved onto
desktop workstations and even personal computers used
at work and home. No longer a system used only by
academics and computing wizards at universities and
research centers, UNIX is used in many businesses,
schools, and homes. As time goes on, more people will
come into contact with UNIX.

You may have used UNIX at your school, office, or home


to run your applications, print documents, and read your
electronic mail. But have you ever thought about the
process that happens when you type a command and hit
RETURN?

Several layers of events take place whenever you enter a


command, but we're going to consider only the top layer,
known as the shell. Generically speaking, a shell is any
user interface to the UNIX operating system, i.e., any
program that takes input from the user, translates it into
instructions that the operating system can understand, and
conveys the operating system's output back to the user.

34
Figure 1-1 shows the relationship between user, shell, and
operating system.

Figure 1-1. The shell is a layer around the


UNIX operating system

There are various types of user interfaces. bash belongs to


the most common category, known as character-based
user interfaces. These interfaces accept lines of textual
commands that the user types in; they usually produce
text-based output. Other types of interfaces include the
increasingly common graphical user interfaces (GUI),
which add the ability to display arbitrary graphics (not
just typewriter characters) and to accept input from a
mouse or other pointing device, touch-screen interfaces
(such as those on some bank teller machines), and so on.

35
What Is a Shell?
The shell's job, then, is to translate the user's command
lines into operating system instructions. For example,
consider this command line:

sort -n phonelist > phonelist.sorted

This means, "Sort lines in the file phonelist in numerical


order, and put the result in the file phonelist.sorted."
Here's what the shell does with this command:

1. Breaks up the line into the pieces sort, -n,


phonelist, >, and phonelist.sorted. These pieces
are called words.

2. Determines the purpose of the words: sort is a


command, -n and phonelist are arguments, and >
and phonelist.sorted, taken together, are I/O
instructions.

3. Sets up the I/O according to > phonelist.sorted


(output to the file phone list.sorted) and some
standard, implicit instructions.

4. Finds the command sort in a file and runs it with


the option -n (numerical order) and the argument
phonelist (input filename).

36
Of course, each of these steps really involves several
substeps, each of which includes a particular instruction
to the underlying operating system.

Remember that the shell itself is not UNIX—just the user


interface to it. UNIX is one of the first operating systems
to make the user interface independent of the operating
system.

37
Scope of This Book
In this book you will learn about bash, which is one of
the most recent and powerful of the major UNIX shells.
There are two ways to use bash: as a user interface and as
a programming environment.

This chapter and the next cover interactive use. These two
chapters should give you enough background to use the
shell confidently and productively for most of your
everyday tasks.

After you have been using the shell for a while, you will
undoubtedly find certain characteristics of your
environment (the shell's "look and feel") that you would
like to change, and tasks that you would like to automate.
Chapter 3 shows several ways of doing this.

Chapter 3 also prepares you for shell programming, the


bulk of which is covered in Chapter 4 through Chapter 6.
You need not have any programming experience to
understand these chapters and learn shell programming.
Chapter 7 and Chapter 8 give more complete descriptions
of the shell's I/O and process-handling capabilities, while
Chapter 9 discusses various techniques for debugging
shell programs.

You'll learn a lot about bash in this book; you'll also learn
about UNIX utilities and the way the UNIX operating

38
system works in general. It's possible to become a
virtuoso shell programmer without any previous
programming experience. At the same time, we've
carefully avoided going into excessive detail about UNIX
internals. We maintain that you shouldn't have to be an
internals expert to use and program the shell effectively,
and we won't dwell on the few shell features that are
intended specifically for low-level systems programmers.

39
History of UNIX Shells
The independence of the shell from the UNIX operating
system per se has led to the development of dozens of
shells throughout UNIX history—although only a few
have achieved widespread use.

The first major shell was the Bourne shell (named after its
inventor, Steven Bourne); it was included in the first
popular version of UNIX, Version 7, starting in 1979.
The Bourne shell is known on the system as sh. Although
UNIX has gone through many, many changes, the Bourne
shell is still popular and essentially unchanged. Several
UNIX utilities and administration features depend on it.

The first widely used alternative shell was the C shell, or


csh. This was written by Bill Joy at the University of
California at Berkeley as part of the Berkeley Software
Distribution (BSD) version of UNIX that came out a
couple of years after Version 7.

The C shell gets its name from the resemblance of its


commands to statements in the C Programming
Language, which makes the shell easier for programmers
on UNIX systems to learn. It supports a number of
operating system features (e.g., job control; see Chapter
8) that were unique to BSD UNIX but by now have
migrated to most other modern versions. It also has a few

40
important features (e.g., aliases; see Chapter 3) that make
it easier to use in general.

In recent years a number of other shells have become


popular. The most notable of these is the Korn shell. This
shell is a commercial product that incorporates the best
features of the Bourne and C shells, plus many features of
its own.[1] The Korn shell is similar to bash in most
respects; both have an abundance of features that make
them easy to work with. The advantage of bash is that it
is free. For further information on the Korn shell see
Appendix A.

The Bourne Again Shell


The Bourne Again shell (named in punning tribute to
Steve Bourne's shell) was created for use in the GNU
project.[2] The GNU project was started by Richard
Stallman of the Free Software Foundation (FSF) for the
purpose of creating a UNIX-compatible operating system
and replacing all of the commercial UNIX utilities with
freely distributable ones. GNU embodies not only new
software utilities, but a new distribution concept: the
copyleft. Copylefted software may be freely distributed so
long as no restrictions are placed on further distribution
(for example, the source code must be made freely
available).

bash, intended to be the standard shell for the GNU


system, was officially "born" on Sunday, January 10,

41
1988. Brian Fox wrote the original versions of bash and
readline and continued to improve the shell up until 1993.
Early in 1989 he was joined by Chet Ramey, who was
responsible for numerous bug fixes and the inclusion of
many useful features. Chet Ramey is now the official
maintainer of bash and continues to make further
enhancements.

In keeping with the GNU principles, all versions of bash


since 0.99 have been freely available from the FSF. bash
has found its way onto every major version of UNIX and
is rapidly becoming the most popular Bourne shell
derivative. It is the standard shell included with Linux, a
widely used free UNIX operating system, and Apple's
Mac OS X.

In 1995 Chet Ramey began working on a major new


release, 2.0, which was released to the public for the first
time on December 23, 1996. bash 2.0 added a range of
new features to the old release (the one before being
1.14.7) and brought the shell into better compliance with
various standards. bash 3.0 improves on the previous
version and rounds out the feature list and standards
compliance.

This book describes bash 3.0. It is applicable to all


previous releases of bash. Any features of the current
release that are different in, or missing from, previous
releases will be noted in the text.

42
Features of bash
Although the Bourne shell is still known as the "standard"
shell, bash is becoming increasingly popular. In addition
to its Bourne shell compatibility, it includes the best
features of the C and Korn shells as well as several
advantages of its own.

bash's command-line editing modes are the features that


tend to attract people to it first. With command-line
editing, it's much easier to go back and fix mistakes or
modify previous commands than it is with the C shell's
history mechanism—and the Bourne shell doesn't let you
do this at all.

The other major bash feature that is intended mostly for


interactive users is job control. As Chapter 8 explains, job
control gives you the ability to stop, start, and pause any
number of commands at the same time. This feature was
borrowed almost verbatim from the C shell.

The rest of bash's important advantages are meant mainly


for shell customizers and programmers. It has many new
options and variables for customization, and its
programming features have been significantly expanded
to include function definition, more control structures,
integer arithmetic, advanced I/O control, and more.

43
[1]
The Korn shell can be downloaded for free but it
comes with a license that will require payment if the shell
is used in certain situations.
[2]
GNU is a recursive acronym, standing for "GNU's Not
UNIX."

44
Getting bash
You may or may not be using bash right now. Your
system administrator probably set your account up with
whatever shell he uses as the "standard" on the system.
You may not even have been aware that there is more
than one shell available.

Yet it's easy for you to determine which shell you are
using. Log in to your system and type echo $SHELL at
the prompt. You will see a response containing sh, csh,
ksh, or bash; these denote the Bourne, C, Korn, and bash
shells, respectively. (There's also a chance that you're
using another shell such as tcsh.)

If you aren't using bash and you want to, then you first
need to find out if it exists on your system. Just type
bash. If you get a new prompt consisting of some
information followed by a dollar sign (e.g., bash3 $ ),
then all is well; type exit to go back to your normal shell.

If you get a "not found" message, your system may not


have it. Ask your system administrator or another
knowledgeable user; there's a chance that you might have
some version of bash installed on the system in a place
(directory) that is not normally accessible to you. If not,
read Chapter 11 to find out how you can obtain a version
of bash.

45
Once you know you have bash on your system, you can
invoke it from whatever other shell you use by typing
bash as above. However, it's much better to install it as
your login shell, i.e., the shell that you get automatically
whenever you log in. You may be able to do the
installation by yourself. Here are instructions that are
designed to work on the widest variety of UNIX systems.
If something doesn't work (e.g., you type in a command
and get a "not found" error message or a blank line as the
response), you'll have to abort the process and see your
system administrator. Alternatively, turn to Chapter 12
where we demonstrate a less straightforward way of
replacing your current shell.

You need to find out where bash is on your system, i.e.,


in which directory it's installed. You might be able to find
the location by typing whereis bash (especially if you are
using the C shell); if that doesn't work, try whence bash,
which bash, or this complex command:[3]

grep bash /etc/passwd | awk -F: '{print $7}' | sort -u

You should see a response that looks like /bin/bash or


/usr/local/bin/bash.

To install bash as your login shell, type chsh bash-name,


where bash-name is the response you got to your whereis
command (or whatever worked). For example:

% chsh /usr/local/bin/bash

You'll either get an error message saying that the shell is


invalid, or you'll be prompted for your password.[4] Type

46
in your password, then log out and log back in again to
start using bash.

[3]
Make sure you use the correct quotation mark in this
command: ' rather than `.
[4]
For system security reasons, only certain programs are
allowed to be installed as login shells.

47
Interactive Shell Use
When you use the shell interactively, you engage in a
login session that begins when you log in and ends when
you type exit or logout or press CTRL-D. [5] During a
login session, you type in command lines to the shell;
these are lines of text ending in RETURN that you type in
to your terminal or workstation.

By default, the shell prompts you for each command with


an information string followed by a dollar sign, though as
you will see in Chapter 3, the entire prompt can be
changed.

Commands, Arguments, and


Options
Shell command lines consist of one or more words, which
are separated on a command line by blanks or TABs. The
first word on the line is the command. The rest (if any)
are arguments (also called parameters) to the command,
which are names of things on which the command will
act.

For example, the command line lp myfile consists of the


command lp (print a file) and the single argument myfile.

48
lp treats myfile as the name of a file to print. Arguments
are often names of files, but not necessarily: in the
command line mail cam, the mail program treats cam as
the username to which a message will be sent.

An option is a special type of argument that gives the


command specific information on what it is supposed to
do. Options usually consist of a dash followed by a letter;
we say "usually" because this is a convention rather than
a hard-and-fast rule. The command lp -h myfile contains
the option -h, which tells lp not to print the "banner page"
before it prints the file.

Sometimes options take their own arguments. For


example, lp -d lp1 -h myfile has two options and one
argument. The first option is -d lp1, which means "Send
the output to the printer (destination) called lp1." The
second option and argument are the same as in the
previous example.

[5]
The shell can be set up so that it ignores a single
CTRL-D to end the session. We recommend doing this,
because CTRL-D is too easy to type by accident. See the
section on options in Chapter 3 for further details.

49
Files
Although arguments to commands aren't always files,
files are the most important types of "things" on any
UNIX system. A file can contain any kind of information,
and indeed there are different types of files. Three types
are by far the most important:

Regular files
Also called text files; these contain readable
characters. For example, this book was created from
several regular files that contain the text of the book
plus human-readable formatting instructions to the
troff word processor.

Executable files
Also called programs; these are invoked as
commands. Some can't be read by humans;
others—the shell scripts that we'll examine in this
book—are just special text files. The shell itself is a
(non-human-readable) executable file called bash.

Directories
These are like folders that contain other
files—possibly other directories (called
subdirectories).

50
Exploring the Variety of Random
Documents with Different Content
“I will open it,” said the chief. “The paper shall be removed and
destroyed at once.”
He examined the ball closely and then pressed hard on a certain
spot. Immediately it flew open in his hands!
Then there was a cry of anger and fury from the lips of the man.
“A thousand fiends!” he shouted. “It is empty!”
The hollow ball did not contain the torn paper they had expected
to find!
“Empty?” gasped the others.
“Yes! It has been opened, and the paper has been removed!”
The captive bound to the pillar laughed. They turned on him in
fury.
“You found the way to open the ball, and you removed the paper!”
snarled the chief. “Tell us where it is, you American meddler!”
“You are entirely wrong,” coolly said Frank. “I am certain the ball
has not been opened since it came into my possession, and I know
nothing of the paper it contained.”
“Don’t lie!”
“I am not lying.”
“What shall we do with him, brothers?” asked the chief.
There was a sudden swishing ring of steel, and seven bright
swords came leaping from their scabbards into the hands of their
owners.
“We must destroy him!” said the hooded band.
Seven swords were pointed at Frank’s breast.
“For the honor of France he must die!” declared the chief. “When I
have counted to three, each man shall plunge his sword through the
captive’s body!”
He was not given an opportunity to count. There came a sudden
thundering and hammering at the door. Then there was a summons
to open in the name of France.
“The gendarmes!” gasped the Black Brothers. “They have tracked
us here! They have located us at last!”
Bang! bang! bang!
The hammering at the door was furious and terrible.
Crash!—the door was falling!
In a moment the seven members of the murderous band took to
flight, escaping from the cellar by the other door, and when the
officers came swarming down the stairs, they found no one to
arrest, but were greeted politely and cheerfully by the young
American who stood with his back bound against a pillar in the
middle of the cellar.
CHAPTER XV.

ANOTHER WARNING.

Frank’s adventures preceding his incarceration in the cellar, from


which he was rescued by the gendarmes, can be briefly told. As
soon as he realized that the Brothers had doomed him to death, and
that his every move was shadowed, he set himself earnestly to the
task of hunting down the band of assassins.
First he went to the police, and told the story of the mystery
connected with the death of the Duke of Benoit du Sault, omitting all
mention of the metal ball which he knew would be taken from him if
he mentioned its existence. His story was laughed at by the police.
They seemed to regard him as a crank, a person deranged, or one
seeking notoriety, and treated him with small courtesy.
His reception at the hands of the police was so discouraging that if
he were not filled with the purpose to render every aid in his power,
under the present circumstances, to the poor prisoner of Devil’s
Island, he would have been disheartened. He made an attempt to
locate the band, in order to lay before the police absolute evidence
of such an organization, and thus it happened, while working on the
case alone, he fell into the hands of the dreadful seven, and was
taken captive to the cellar.
When the force of gendarmes rushed in, there was Frank bound to
the pillar. The capture of the conspirators, rather than the rescue of
their late prisoner, seemed to be their purpose. Pausing to question
as to the direction of the flight of the Brothers, they made off in
pursuit without making the least effort to release the captive from
his bonds.
Down the stairs came a man who walked with dignity, but who
was followed by a wildly excited youth. The youth was Jack
Diamond. The man was the mysterious Mr. Noname.
“Here he is,” quietly said the Man Without a Name, as he caught
sight of Frank.
Jack gave a shout of joy and rushed forward.
“Frank, are you alive?”
“Sure thing,” laughed the nervy young American. “But the
gendarmes came at just the right moment. If they had delayed ten
seconds longer, you’d have found me with seven large holes in my
skin.”
“I brought them here,” said Mr. Noname.
“Then I again owe you my life,” came with genuine thankfulness
from Merriwell. “The debt is getting pretty heavy, sir.”
“There is no debt. I have told you I am your good genius. You
must believe me now.”
“I do! I have believed you for some time. But how can I repay you
for——”
“There is nothing to be repaid. Some day you shall understand
what seems so mysterious now.”
Diamond was hastening to set Frank free. The Virginian knew
better than to question him then and there.
“Thank you,” said Merry, as he stepped away from the pillar,
rubbing his arms to start the circulation. “This is much better. That
position was becoming painful.”
“Where are the devils who brought you here?” hissed Jack.
“They took to flight when the gendarmes began hammering at the
door up there. There was another way out of the cellar, and the
officers are after them.”
“The officers will not capture them,” announced Mr. Noname. “My
mission is complete now that you have been saved.”
Frank seized the strange man’s hand and wrung it warmly. A thrill
shot over him at the touch. It was a most peculiar sensation, and
afterward, when he thought about it, he wondered much.
“Again I must thank you!” said the young American, with deep
feeling. “I do not understand how it is that you always arrive in time
to save me.”
“There is an unseen tie between us. When you are in danger, I am
drawn to you by a power which no man may measure. I feel your
peril, and I hasten to your aid. The stars may fade into endless
night, and the sun may turn to ashes, but death alone can break the
bond between us!”
Strange words, like those that fall from the lips of a person
demented, and yet they impressed Frank Merriwell. Somehow, he
felt that there really was a bond that held this man of mystery and
himself linked together.
“Let’s follow the police!” urged the Virginian. “Let’s help hunt down
those devils!”
“Stop!”
The command came from the lips of Mr. Noname.
“Let them go,” said the man. “You cannot do any good.”
“Let them go!” panted Jack. “Let them get off after they have
nearly murdered my friend! Well, I’m not built that way! If I can do
anything to bring them to justice, you bet I’m going to do it!”
“That is well enough, but you can do nothing.”
“How do you know?”
“I know! The officers will not capture one of them. In a little while,
they will return here. If Mr. Merriwell is here, they will take him into
custody, perhaps. They will ask him a hundred questions. They will
throw a cloud of suspicion over him. They will not believe the story
he tells them. They will have him shadowed when he is set at liberty,
if he is set at liberty. In short, they will make life in Paris rather
unpleasant for him.”
“And you advise—what?”
“That we all get out of here at once, before the officers return.”
“But there are others on guard outside this building,” said Jack.
“I know a way to pass them.”
“He is right,” decided Frank, remembering his unpleasant
experience with the police. “Come.”
“Just as you say,” said Diamond regretfully; “but I’d like to help
mob those whelps.”
They mounted the stairs and clambered over the broken door,
following the Man of Mystery. Above they were in darkness, but he
led them on. Their feet awoke the echoes of empty rooms and
corridors. They passed through doors and made many turns. At last
they stopped. Barely had they done so when, somewhere in the
darkness, a voice was distinctly heard to say:
“The decree is made, the red star has fallen, and Frank Merriwell
is doomed to die!”
The words were distinctly spoken, but it was impossible to tell
from whence they came. Jack Diamond gripped Frank’s arm.
“Do you hear?” he whispered.
A scornful laugh came from Merriwell’s lips.
“I hear,” he said derisively; “but who fears a coward who lurks in
the darkness and spends his breath in threats! It is nothing.”
Then, once more, the voice spoke:
“The days from the falling of the red star till the time of death are
ten, and they are passing!”
Immediately Frank cried:
“Before the ten days are over, the last of the assassin band of
Black Brothers shall meet his just deserts!”
“That is right,” came solemnly from the lips of the Man of Mystery.
“The end of the brotherhood is near!”
These words were spoken in French, and the Man Without a Name
seemed to command the language without an accent to mar his
pronunciation. Following his words, silence reigned in the old
building.
“Let’s get out!” muttered Diamond, who feared no enemy he could
see, but who now felt, despite his courage, a strange chill stealing
through his veins.
The man who was leading them found and opened a door. When
they had passed through, he barred the door behind them, and
again led them on till they stood beneath the open sky. Then, when
Frank turned to speak to the Mystery, who seemed to have halted to
fasten the last door, he found the man had vanished. The door was
closed, and Mr. Noname was not with them!
“Gone!” exclaimed Frank.
“Where?” gasped Jack.
Merry tried the door, but it would not move.
“That must explain it,” he said. “He stepped back through that
door, and closed it behind him.”
“What for?”
“You know as well as I.”
“Don’t say that! This whole affair is a mystery to me. I do not
understand any part of it. You have puzzled me for days by your
strange actions. I knew something was going wrong. To-night, when
I could stand it no longer, I left the hotel, meaning to walk and
think. Almost immediately I ran upon this man who is known as Mr.
Noname. He told me you were in great peril. How did he know
that?”
“How does he know about so many things? You can answer the
question quite as well as I.”
“He led me here, and we found the officers ready to break in. It
seemed that he had told them of your peril, and informed them
where to find you. He showed them how to enter the building and
reach the door at the head of the cellar stairs. Why, he seems to
know almost everything!”
“He is a marvel,” said Frank. “Whoever and whatever he is, I owe
him my life several times over. I shall not forget that.”
“Why doesn’t he come out and tell us who he is? Why does he act
in such a remarkable manner?”
“You can ask a hundred questions about him that I cannot answer.
The only thing of which I am absolutely certain is that he is my
friend.”
“Are you absolutely certain of that?”
“Of course I am! Why do you ask such a question?”
“Because I do not believe you can be certain of anything in
connection with that man.”
“Why not?”
“Something tells me he is crazy, and a crazy man cannot be
trusted.”
“I have every reason to believe he may be trusted fully and
completely, and I shall continue to trust him.”
“Of course you will do as you like about it, Frank.”
To this Merry said nothing in reply, and the two young Americans
made haste to get away from that vicinity. Not far away they found a
Jew’s shop, where Merry procured a coat and hat.
On the way to the hotel, Jack said:
“Don’t you think it is about time to trust me, Frank?”
“I do trust you, old man.”
“You are wrong.”
“How?”
“You have not trusted me of late.”
“In what way?”
“You have had a secret from me. You cannot deny me.”
“Even that is not proof that I do not trust you.”
“Then you confess you have had a secret?” cried the Virginian
eagerly.
“Yes.”
“I knew it!”
“But it has been a secret from all my friends, as well as you.”
“Still you did not dare to trust me!” came reproachfully from
Diamond’s lips.
“That was not my reason for keeping the secret from you, Jack.”
“Wasn’t?”
“No.”
“What was the reason, then?”
“I was pledged to secrecy. I had promised to keep it for a time,
and you know Frank Merriwell never breaks his word.”
“I know that, old man, but——”
“Come into this theater, Jack, and I will tell you all about it.”
They had reached the brilliantly lighted Champs-Élysées, where
the theaters were in full blast, even at that hour. The sound of music
and singing came from the tree-bowered region beyond the archway
of a door, and Diamond followed Merry to the ticket-office. Frank
purchased tickets, and they passed through into the garden, where
hundreds of people were seated beneath the trees, gathered in
groups around little tables, drinking cooling beverages, chatting,
laughing, and seeming to pay very little heed to the singer on the
distant stage. A breath of cool air, the scent of flowers, and the
tinkle of water fountains added to the charm of the place. The
shadows were above the trees, which shut off the electric lights from
the sky. The boys had visited this particular café-chantant before,
and they soon found a table where they could sit and talk without
disturbing anybody. The orchestra sawed away when the singer had
retired, and then two black-face “comedians” came out with banjos,
and prepared to inflict a “turn” on the unresenting spectators.
“Just like a roof-garden act in New York,” said Frank. “I’ll
guarantee those gentlemen will spring the same old gags, done over
into French, and half the jokes will be robbed of their points because
of the translation.”
“Well, we didn’t come here to listen to them,” said the eager and
impatient Southerner. “You were going to tell me something, Merry.”
“Yes,” nodded Frank, as he ordered two lemonades from a waiter,
“I feel free now to tell you the whole story, for the metal ball is no
longer in my possession.”
CHAPTER XVI.

FRANK AND JACK.

“What are you talking about?” asked Jack, in a puzzled way.


“Frank, has anything gone wrong with your brain?”
“I think not,” smiled Merry quietly.
“But you have acted so strangely! This is not the first time you
have spoken of the metal ball, the blood-red star——”
“Which you saw fall before me, and which I have here.”
Frank took the crimson star from his pocket and placed it on the
table before them.
“It is the sign of death!” he said. “It came from the Black Brothers,
from whose hands I was saved this night. There are seven of the
brothers, and there are seven points to the star.”
Diamond gave himself a shake.
“Come, come, Merriwell!” he exclaimed. “What sort of rot is this?
Excuse me for using the word ‘rot,’ but no other word seems
appropriate. It is like a chapter from a sensational story. You haven’t
been reading French detective novels till they have turned your
brain, have you?”
“Nothing of the sort, Diamond,” replied Frank calmly. “I know it
seems most remarkable, and I do not wonder you think it crazy
nonsense. I remember that I thought Edmond Laforce insane.”
“Who is Edmond Laforce?”
“He is, or was, the Duke of Benoit du Sault.”
“But he is dead.”
“Yes, murdered in his bed by the Black Brothers!”
“Nonsense! He died in a perfectly natural manner, of heart failure.”
“All men die of heart failure, but there was a cause for the death
of Edmond Laforce. A star exactly like this one before us had fallen
into his hands, and he was doomed to death. He knew it. He knew
his time was limited to ten days.”
“Why was this?”
“Because he was doing everything in his power to save Dreyfus
from Devil’s Island. Because, through his work, he had become
dangerous to the existence of the Anti-Dreyfus League.”
“The Anti-Dreyfus League? Is there such an organization?”
“Yes.”
“Is it the same as the Black Brothers?”
“No. The Black Brothers are simply the executioners of the great
and powerful league, which contains some of the wealthiest and
most influential men in France. The league is sworn to hold poor
Dreyfus on his prison island. I have learned that not all the members
of the league are aware, that there is a band of assassins connected
with the organization. The league is like a secret order. A man may
join it, and yet he may never be initiated into its deeper mysteries.
He may join it by simply pledging himself to use all ‘honorable’
means to keep Dreyfus on that island. That is the first degree. There
are other degrees, and only the right ones to take them are
advanced. When a man takes the highest degree, he pledges
himself, in case of necessity, to commit murder to perpetuate the
imprisonment of Dreyfus. When he has taken this degree, he knows
all about the Black Brothers, but those who have never advanced
beyond the lower degrees know nothing of the connection of the
league with the seven assassins. They furnish money to be used in
the work of ‘honorably’ keeping Dreyfus on the island, and are quite
unaware that much of that money goes to pay the assassins in
black.”
Jack Diamond listened with increasing astonishment.
“And do you mean to tell me that such things can be here in
France?” he cried.
“Are such things so very strange? You must not forget that it was
here the Commune existed. It was here the bloodiest revolution of
history took place. These streets have run red with human blood!”
“But it seems so calm, so peaceful now! There seems no hint of
anything wrong.”
“The calm is all on the surface. The French people are peculiar. At
any moment the storm may break forth. The men who seem so calm
and happy at one moment, in another instant may turn to wrangling,
raging, bloodthirsty demons. You cannot measure a Frenchman by
the standard of an American. They are different, the same as an
American differs from an Englishman.”
“But how did you learn so much about this league?”
“Since the day the red star fell before me, I have been doing my
best to hunt down the Black Brothers, and gradually I have learned
the things just told you.”
“But this star, Merry, is——”
“The sign the Black Brothers give one who has been doomed to
die by the death council of the league.”
“And you are one?”
“Yes.”
“Why?”
“Because the Duke of Benoit du Sault gave me the metal ball,
which he said contained something that might help prove the
innocence of Dreyfus.”
“When did he give you this?”
“The very night of his death. I met him in the Place de l’Opera. He
had been seized by strange pains in his heart, and I assisted him to
a seat by a table before the Café de la Paix. Those pains alarmed
him. It was the tenth day after he had received the red star. He
thought he might be dying, and, finding I was an American and in
full sympathy with Dreyfus, he entrusted me with the metal ball,
pledging me to secrecy, and making me promise to defend it with
my life, till a person with the proper signal called for it. My promise
of silence has caused me to keep still, and has given you an
opportunity to say I did not trust you.”
Diamond had been intensely interested all along, but now he was
athrob with excitement.
“But you are telling me now!” he exclaimed. “The metal ball—
where is it?”
“Gone.”
“Gone?”
“Yes. I am released from my pledge.”
“You delivered it into the proper hands?”
“No.”
“What then?”
“The Black Brothers took it from me.”
“Then they obtained the precious secret that was to liberate
Dreyfus?”
“Nothing of the sort.”
“They did not?”
“No.”
“Why not?”
“I fancied the secret would become theirs till I saw the chief of the
seven open the ball before me, as I stood bound and helpless, with
my back against that stone pillar.”
“What did it contain?”
“Nothing.”
Jack fell back in his chair.
“It was——”
“Empty,” nodded Frank.
After a little the Virginian eagerly asked:
“How was that? Explain it!”
“I cannot. All I know is that the hollow metal ball which had
caused me so much trouble was perfectly empty. The Black Brothers
were infuriated at the discovery, and my death was set to occur at
once. They drew their swords and were ready to run them through
my body when the first blow fell on the door at the head of the
stairs and the officers demanded admittance.”
Jack was silent, thinking of the wonderful things he had heard.
“I have no doubt but the story seems almost beyond belief,” said
Frank; “but you came with Mr. Noname and found me in the cellar.
You know I did not tie myself to that post. Here is the red star, which
is the sign of death. The metal ball I cannot show you, as that has
passed beyond my possession.”
“Good heavens! What are you going to do, Frank? Why don’t you
get out of Paris and out of France?”
A grim look came to Merry’s face.
“Do you advise me to run away?” he asked. “Would that be
manly?”
“Manly! Merciful goodness! do you think you can defend your life
against the powerful Anti-Dreyfus League and its tools, the Black
Brothers? This Dreyfus affair is nothing to you.”
“You are wrong!”
“How?”
“It is something to every man who loves liberty and justice!”
“But you cannot be willing to sacrifice your life in the cause. It is
not required of you. There are others who may do that.”
“The existence of the league is well known; before I leave France
I am going to try to show that the seven assassins in black are
connected with the league. If I can do that, it may be that the
league will go to pieces, for the decent ones in the lower degrees,
who know nothing of its connection with murderers, may withdraw
and denounce it.”
“And, in the meantime, you may follow other victims of the Black
Brothers! It is horrible to think of! But the papers said the Duke of
Benoit du Sault died a natural death.”
“Because they did not know any better. He was murdered!”
“How?”
“That is yet a mystery. I have thought much about it. I remember
that he told me of an encounter with a bold woman of the streets.
When he repulsed her, she struck him with a pin, inflicting a wound
on his left wrist. That was bleeding when he was attacked by the
pains. I remember that, from his manner, it seemed that the pains
shot up his arm.”
“Then you think the wound on his wrist may have——Oh, pshaw!
That must be nonsense, Frank! That could not have killed him.
Those pains were brought on by the excitement of the encounter
with the woman. His heart had been wrong all along, and it failed
him that night.”
“Still,” said Frank Merriwell, “you must admit it is most singular
that that night was the tenth one after he received a star exactly like
this blood-red one I hold in my hand.”
Diamond was more deeply impressed than he wished to
acknowledge. He did not wish to believe that Merry, his friend, had
been selected as a victim by the dreaded Black Brothers.
He had been with Frank when the red star fell on Merry’s plate
one day at a queer little restaurant, where they were taking lunch.
At the time he observed the remarkable change that came over his
friend, who, having been gay and light-hearted, suddenly grew sober
and stern. Jack thought about this now. He thought of other things
which had seemed so mysterious to him, and he did not wonder at
Merry’s strange acts. Still, it was most remarkable that Frank, a
stranger and a foreigner, had been drawn into the affair.
Jack’s sympathy was with the unfortunate prisoner of Devil’s
Island, believing Dreyfus had been unfairly and unjustly condemned,
but, hot-blooded though he was, he felt certain he would have a
care not to permit himself to become involved as Frank had been.
But Diamond was not one to reproach a friend, or to desert him in
the hour of trouble. He was ready to stand by Frank through any
peril.
That Frank was in great peril he could no longer doubt. That Frank
had been condemned to die by the Anti-Dreyfus League was
apparent. Jack’s soul rebelled at the thought that such a thing could
be in a city like Paris. And it was terrible to fancy that Merry might
come to his end as had the Duke of Benoit du Sault, without a single
mark being left on his body to tell how his death had been
accomplished.
Jack leaned across the table and spoke earnestly.
“Why should you stay here in Paris, Frank, and wait for those
murderous wretches to accomplish their dastardly work? Why don’t
you get out? There is nothing to keep us here. In fact, I am
beginning to feel that I have seen enough of this place.”
“And it was only yesterday,” retorted Frank, with a smile, “that you
said you could live a year in Paris without getting tired.”
“Did I say that?”
“Sure.”
“Well, I’ve changed my mind. If you were fighting an enemy like
Harris or Brattle, it would be different. By the way, where is Brattle?”
“You tell.”
“He has disappeared.”
“Completely.”
“Perhaps he is connected with the very ones who are doing their
best to snuff you out.”
“Not likely. They would not trust him.”
“And yet he may have aided to throw suspicion on you.”
“It is possible, but does not seem probable.”
Frank Merriwell sipped his lemonade, which had been served,
seeming cool and unconcerned, as if deadly danger had never
visited him in all his life. The black-face comedians had retired, and
there was a sudden burst of applause, as a popular chanteuse
appeared. She began to sing, and the young Americans resumed
their conversation.
“I do not feel like running away now,” said Merry grimly.
“You know the old saying,” muttered Jack: “‘He who fights and
runs away,’ etc.”
“I know, but there is no reason why I should run. I can do the
anti-Dreyfus men no harm now.”
“Perhaps they do not know that. Your sympathy is with Dreyfus?”
“Yes. I believe he was unjustly condemned. I believe everything
points to Esterhazy as the guilty man.”
“But the bordereau, the paper which convicted him——”
“Was forged by Esterhazy, I firmly believe. Of late, everything has
tended to prove that. There was no real reason why Dreyfus should
have acted as a traitor. It could not have been from anger or
disappointment, as he had the finest prospects of an excellent
military career.”
“And Esterhazy——”
“Always an adventurer and a soldier of fortune, always begging
money from the money-lenders, always extravagant and dissolute,
there were many reasons why he might have been guilty. Letters of
his, which he cannot deny, and in which he abused France
unmercifully, have been found. Those letters are in the possession of
the friends of Dreyfus, and will be used at the proper time.”
“But it has been claimed that Dreyfus was dissolute, that he was a
gambler, and an associate of the low and vicious.”
“It has been claimed, but it has not been proven. Instead, in many
instances, it has been shown conclusively that such charges against
him were utterly false. It has been shown that others by the name
of Dreyfus have been confounded with him. I do not suppose he was
a man without faults, but those faults and failings make his unjust
and cruel condemnation none the less horrible.”
“You feel strongly about this, Frank.”
“I do! I confess it. And I feel more strongly now than ever before.
I feel like going into this thing deeply, but it now seems that I have
done everything in my power, and that has proved to be—nothing!”
“Have you other reasons to believe Dreyfus innocent?”
“Yes. It has been shown that he was not even aware of some of
the secrets given away in the forged papers. He had not been placed
in position to acquire the knowledge contained in those papers. The
dastards who sought his ruin incorporated in the papers what they
thought he knew, but they were wrong.”
“This being the case, how is it possible to hold him longer on
Devil’s Island without a fair and open trial?”
“In America or England it would not be possible. In France it is
different. He is a Jew, and you see the powerful feeling that has
been aroused against the Jews. He was condemned by the army,
and it is a firmly entrenched belief in this country that the army can
do no wrong. To give him another trial now, at which he might be
able to clear himself fully, would be to confess that there was a
possible doubt in the matter. That, it is said, would throw discredit
on the army. If he were to be shown innocent, it might bring on a
revolution.”
“And so they are going to let an innocent man rot on Devil’s Island
rather than give him justice and confess that a terrible wrong has
been done?”
“You must remember that it is ‘for the honor of France!’”
“It is the dishonor of France!” exclaimed Diamond hotly. “It means
the eternal disgrace of France!”
“The day must come when the whole truth will be known.”
In this speech Frank was prophetic. The day did come when the
whole wretched conspiracy came to light, and the unfortunate
Dreyfus was publicly proclaimed innocent.
“So much the worse for France if Dreyfus dies on that island.”
“You are getting warm over it, Jack,” laughed Merry.
“A trifle,” confessed the Virginian. “Who wouldn’t?”
“It is enough to warm up almost anybody,” agreed Frank. “I think
you begin to understand how I feel. And you must see why I
guarded that ball with my very life.”
“But that contained nothing.”
“When it was opened it contained nothing. I believe there was a
time when it contained a paper that would have aided in proving
Dreyfus innocent.”
There was a low, musical laugh near at hand, and a voice spoke in
French, saying:
“Messieurs, you are so eager, so earnest! I wonder what it can be
you talk of so animatedly? It cannot be of Mademoiselle Held, for
you have scarcely glanced toward the stage. Yet I’ll wager I can read
the truth in your faces and tell you your very thoughts.”
A woman, slender, supple, graceful, attired in airy evening-dress,
with a mask hiding the upper part of her face, stood beside the
table. Without being invited, she sat down there.
CHAPTER XVII.

MADEMOISELLE NAMELESS.

Both lads were surprised, not to say startled. She saw this plainly,
and laughed softly, fluttering a jeweled fan.
“You are Americans,” she said positively. “You are not accustomed
to some things you find in Paris.”
“That is very true,” murmured Jack Diamond, a frown on his face.
Frank lay back in his chair and studied the woman. He saw she
had a beautiful neck and chin, while there was something strangely
fascinating about the eyes seen through the twin holes in the mask.
They were coal-black, like her hair, and seemed forever in motion.
When the woman’s lips parted, she showed two rows of pearly
teeth.
“How do you think I know you are Americans?” she asked.
“Give it up,” said Diamond.
“I know—I read it in your face. I can read other things there. I
read that you are friends—very great friends.”
“Astonishing!” said Jack, with mild sarcasm, while Frank continued
to keep silent.
The woman turned on Merry.
“You are so still all at once! You suspect something—me? Ha! ha!
ha! Because I wear this mask? Oh, no, no! Why, I can do that here.
No one minds it. They know me. I tell them their fortunes. All have
heard me. You want me to tell your fortune—yes?”
She leaned forward, seeming to peer more closely into Frank’s
face.
“Your past is all written there,” she declared. “I see it plain. In
America, though young, already you are famous. It is wonderful! No
man as young as you has ever become so famous in America. You
are known all over the land, and there all young men long to be like
you.”
Frank smiled.
“I fear you are given to exaggeration and flattery,” he said.
She shook her head.
“I speak the truth as I read it. Is it not true?”
She turned in her appeal to Jack. The Virginian remembered how
famous Frank had become in a short time, and he said:
“To some extent it is true, but it’s an easy guess.”
The woman shrugged her shapely shoulders and fluttered her fan.
“Oh, not so easy!” she exclaimed. “I have but begun. When I am
done, say I am an impostor—if you can.”
“I beg your pardon,” came quietly from Frank; “I must tell you
honestly that I take no stock in the mummery of fortune-telling. I do
not wish to seem rude, but you are interrupting——”
“I know; still you will thank me when I am done. I am going to tell
you of the terrible dangers you have been in, of the deadly perils to
come, and how you may escape them. This night you have been in
danger! This night you have been close to death! You escaped by a
miracle.”
“Where were you that you learned so much?”
“I read it in your face, but the stars tell me many things. To-night
the stars have told me of you, Frank Merriwell.”
She knew his name!
Frank’s interest increased swiftly, and she laughed as she saw it.
“I knew you would listen,” she declared. “No one refuses to listen
to me.”
“You must have been listening to our conversation,” said Diamond.
Again she shrugged her shoulders.
“I do not need to do that. I heard some words just when I came
up. I heard you speak of Dreyfus, the traitor. But I did not need that
to tell me you were interested in him. You hope to see him free
again.”
“As hope thousands of good citizens of France.”
“No; they are not good citizens! But why argue! It was not for that
I sat here. I was tired, and I needed amusement. It would amuse
me to astonish you by reading your fortune. Monsieur Merriwell was
warned of his danger. He might have escaped it, but he chose not to
do so. He came near losing his life. If he heeds not the warning he
has received, he will yet lose his life.”
“How do you know so much?” cried Jack.
“You must be connected with the Anti-Dreyfus League,” muttered
Frank.
She shook her head.
“It is not well for a foreigner to come to France and have so much
knowledge. It is not fortunate for him if he meets wrong ones and
takes too much interest in Dreyfus, the Jew. It may be thought he
has come to France for that very reason, and then his peril shall be
great, for hundreds of good men have sworn to protect the honor of
France with their very lives.”
“Who are you that knows so much?” asked Frank sharply.
“I am called Mademoiselle Nameless.”
“Nameless?” muttered Jack, instantly thinking of the man who
called himself “Mr. Noname.”
“Yes, I am called that, and it is enough for you to know me by
that name.”
“Why do you refuse to tell us your true name?” asked Merry.
“My true name is something I tell nobody.”
“Then remove your mask and show your face.”
She drew back.
“If I see fit to warn you of your great danger, and still keep my
face concealed, I have a right.”
“You cannot explain how it is you know so much.”
“The stars conceal nothing from Mademoiselle Nameless.”
“You cannot make a level-headed American take stock in such
trash.”
“It matters little. You must know I have told you nothing but the
truth. There is but one thing for you to do, Frank Merriwell. You have
been marked for death, and there is but one way to escape.”
“How is that?”
“Abandon everything and fly from France without delay.”
“Like a cowardly cur!” exclaimed Merry. “No, thank you!”
“Beware!”
“If I am murdered, it will simply be another human life added to
the list set against the wretches who are exerting every power to
keep an innocent man on Devil’s Island. I know all about the time-
limit, and I have yet several days left before the murderous band will
carry their threat into full execution.”
“You cannot be sure of that.”
“It has been thus with others.”
“But you have lifted your hands against those who seek to protect
the honor of France.”
“I’ve simply tried to expose the human whelps who seek to
murder me!”
“It is enough. By that you have added to the peril that besets you.
At any time destruction may swoop down upon you. Heed my
warning. Fly from France!”
“Oh, I rather think you are making this thing much worse than it
really is.”
“Not the least.”
“If I am slain by the Black Brothers, I have friends who will take
my place in the work of hunting the dastardly band down.”
“There will be no proof that you are slain by them. Remember
how others have fallen. There were no marks of violence on them.
The thought should chill your heart with terror. I tell you to go,
Monsieur Merriwell. I beg you to go. It is your only way to escape
death. You must listen to me.”
She leaned on the table, all eagerness and excitement, her eyes
dancing. Somehow those eyes made Frank think of a snake. They
seemed to fascinate him.
“Tell me why you are so eager for me to go?” he asked.
“I cannot tell you, save that I am earnest, for I know what it
means to you. Promise me you will drop this Dreyfus affair and leave
the country. If you do that, your life may be spared. If you do not
promise, your doom is sealed, and death may swoop down on you at
any moment.”
“It is remarkable that you should know so much about me, a
stranger, and take so much interest in me. I believe you must
somehow get close to the Black Brothers. Can you deny it?”
“I deny nothing!” she proudly cried. “You may think what you like!
I have warned you. Once, for the last time, I tell you your doom is
sealed!”
She had closed her fan, and now she leaned across the table,
reaching as if she would tap Frank on the wrist with it, by the way of
emphasis. It was his left wrist she attempted to touch with the fan.
And he had no warning thrill to tell him of the frightful peril that
was so near.
A hand came down over the woman’s shoulder, grasped her wrist,
held it! Another hand snatched that fan from her grasp before it had
touched Frank Merriwell!
“Even the rattlesnake gives warning before striking!” said a deep,
well-known voice.
“Mr. Noname!” exclaimed Frank.
It was the Mystery who had suddenly appeared and snatched the
fan from the woman’s hand.
“Mr. Noname and Mademoiselle Nameless!” murmured Jack
Diamond, looking from one to the other. “Which is the greater
mystery?”
The woman had fallen back in her chair, and she was staring at
the Mystery through the twin holes in her sable mask, her bosom
rising and falling tumultuously. The Man Without a Name fixed her
with a steady, piercing, accusing look. There was horror and
condemnation in his gaze, and she seemed to feel it.
“When the enemies of Dreyfus are forced to get a woman to do
their wretched work of murder, they have fallen pretty low!” said the
man, with deep contempt.
“Murder?” came from Frank.
“What does he mean?” gasped Jack.
The woman seemed to force a laugh from her lips, which had
grown colorless beneath their rouge.

You might also like