E-Book, Englisch, 350 Seiten
Johnson Pro Bash Programming
1. ed
ISBN: 978-1-4302-1998-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Scripting the Linux Shell
E-Book, Englisch, 350 Seiten
ISBN: 978-1-4302-1998-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
The bash shell is a complete programming language, not merely a glue to combine external Linux commands. By taking full advantage of shell internals, shell programs can perform as snappily as utilities written in C or other compiled languages. And you will see how, without assuming Unix lore, you can write professional bash 4.0 programs through standard programming techniques. Complete bash coverage Teaches bash as a programming language Helps you master bash 4.0 features
Chris F.A. Johnson was introduced to Unix in 1990 and learned shell scripting because there was no C compiler on the system. His first major project was a menu-driven, user-extensible database system with report generator. Chris uses the shell as his primary, general-purpose programming language, and his projects have included a member database, menuing system, and POP3 mail filtering and retrieval. Chris is the author of Shell Scripting Recipes: A Problem-Solution Approach (Apress, 2005). When not pushing shell scripting to the limit, he designs and codes web sites, teaches chess, and composes cryptic crosswords.
Autoren/Hrsg.
Weitere Infos & Material
1;Contents at a Glance;4
2;Contents;5
3;About the Author;16
4;About the Technical Reviewer;17
5;Introduction;18
5.1;Why the Shell?;18
5.2;Just the Shell, Ma’am, Just the Shell;19
5.3;A Brief History of sh;19
5.4;Which Version of Bash?;19
5.5;Who Will Benefit from This Book?;19
5.6;What’s in the Book?;20
5.7;Downloading the Code;21
5.8;Contacting the Author;21
6;Hello, World! Your First Shell Program;22
6.1;The Code;22
6.2;The File;23
6.3;Choosing and Using a Text Editor;24
6.4;Building a Better “Hello, World!”;26
6.5;Summary;26
6.6;Exercises;27
7;Input, Output, and Throughput;28
7.1;Parameter and Variables;28
7.2;Arguments and Options;29
7.3;echo, and Why You Should Avoid It;30
7.4;printf: Formatting and Printing Data;30
7.5;Line Continuation;34
7.6;Standard Input/Output Streams and Redirection;34
7.7;Reading Input;36
7.8;Pipelines;36
7.9;Command Substitution;37
7.10;Summary;37
7.11;Exercises;38
8;Looping and Branching;39
8.1;Exit Status;39
8.2;Testing an Expression;39
8.3;Lists;42
8.4;Conditional execution;42
8.5;Looping;45
8.6;Summary;47
8.7;Exercises;48
9;Command-Line Parsing and Expansion;49
9.1;Quoting;50
9.2;Brace Expansion;51
9.3;Tilde Expansion;52
9.4;Parameter and Variable Expansion;53
9.5;Arithmetic Expansion;53
9.6;Command Substitution;55
9.7;Word Splitting;56
9.8;Pathname Expansion;57
9.9;Process Substitution;57
9.10;Parsing Options;58
9.11;Summary;61
9.12;Exercises;61
10;Parameters and Variables;62
10.1;The Scope of a Variable: Can You See It from Here?;62
10.2;Shell Variables;63
10.3;The Naming of Variables;65
10.4;Parameter Expansion;65
10.5;Positional Parameters;72
10.6;Arrays;73
10.7;Summary;75
10.8;Exercises;76
11;Shell Functions;77
11.1;Definition Syntax;77
11.2;Compound Commands;79
11.3;Getting Results;80
11.4;Function Libraries;82
11.5;Sample Script;82
11.6;Summary;84
11.7;Exercises;84
12;String Manipulation;85
12.1;Concatenation;85
12.2;Processing Character by Character;87
12.3;Case Conversion;88
12.4;Comparing Contents Without Regard to Case;90
12.5;Check for Valid Variable Name;91
12.6;Insert One String into Another;92
12.7;Overlay;92
12.8;Trim Unwanted Characters;93
12.9;Index;95
12.10;Summary;96
12.11;Exercises;96
13;File Operations and Commands;97
13.1;Reading a File;97
13.2;External Commands;99
13.3;Regular Expressions;103
13.4;File Name Expansion Options;107
13.5;Summary;112
13.6;Exercises;113
14;Reserved Words and Builtin Commands;114
14.1;help, Display Information About Builtin Commands;114
14.2;time, Print Time Taken for Execution of a Command;115
14.3;read, Read a Line from an Input Stream;116
14.4;type, Display Information About Commands;123
14.5;builtin, Execute a Builtin Command;125
14.6;command, Execute a Command or Display Information About Commands;125
14.7;pwd, Print the Current Working Directory;125
14.8;Deprecated Builtins;126
14.9;Dynamically Loadable Builtins;126
14.10;Summary;127
14.11;Exercises;128
15;Writing Bug-Free Scripts and Debugging the Rest;129
15.1;Prevention Is Better Than Cure;129
15.2;Debugging a Script;136
15.3;Summary;139
15.4;Exercises;139
16;Programming for the Command Line;140
16.1;Manipulating the Directory Stack;140
16.2;Filesystem Functions;144
16.3;Miscellaneous Functions;147
16.4;Managing Man Pages;148
16.5;Games;149
16.6;Summary;155
16.7;Exercises;155
17;Runtime Configuration;156
17.1;Defining Variables;156
17.2;Command-Line Options and Arguments;156
17.3;Menus;157
17.4;Q&A Dialogue;158
17.5;Configuration Files;158
17.6;Scripts with Several Names;159
17.7;Environment Variables;161
17.8;All Together Now;161
17.9;Summary;171
17.10;Exercises;171
18;Data Processing;172
18.1;Arrays;172
18.2;Data File Formats;186
18.3;Summary;191
18.4;Exercises;192
19;Scripting the Screen;193
19.1;Teletypewriter vs. Canvas;193
19.2;Stretching the Canvas;194
19.3;Priming the Canvas;195
19.4;Moving the Cursor;195
19.5;Changing Rendition Modes and Colors;196
19.6;Placing a Block of Text on the Screen;197
19.7;Scrolling Text;200
19.8;Rolling Dice;201
19.9;Summary;203
19.10;Exercises;203
20;Entry-Level Programming;204
20.1;Single-Key Entry;204
20.2;History in Scripts;210
20.3;Sanity Checking;211
20.4;Form Entry;212
20.5;Reading the Mouse;213
20.6;Summary;217
20.7;Exercises;217
21;Shell Variables;218
21.1;BASH;218
21.2;BASHPID;218
21.3;BASH_ALIASES;218
21.4;BASH_ARGC;218
21.5;BASH_ARGV;219
21.6;BASH_CMDS;219
21.7;BASH_COMMAND;219
21.8;BASH_EXECUTION_STRING;219
21.9;BASH_LINENO;219
21.10;BASH_REMATCH;219
21.11;BASH_SOURCE;220
21.12;BASH_SUBSHELL;220
21.13;BASH_VERSINFO;220
21.14;BASH_VERSION;220
21.15;COMP_CWORD;220
21.16;COMP_KEY;220
21.17;COMP_LINE;221
21.18;COMP_POINT;221
21.19;COMP_TYPE;221
21.20;COMP_WORDBREAKS;221
21.21;COMP_WORDS;221
21.22;DIRSTACK;221
21.23;EUID;222
21.24;FUNCNAME;222
21.25;GROUPS;222
21.26;HISTCMD;222
21.27;HOSTNAME;222
21.28;HOSTTYPE;222
21.29;LINENO;223
21.30;MACHTYPE;223
21.31;OLDPWD;223
21.32;OPTARG;223
21.33;OPTIND;223
21.34;OSTYPE;223
21.35;PIPESTATUS;223
21.36;PPID;224
21.37;PWD;224
21.38;RANDOM;224
21.39;REPLY;224
21.40;SECONDS;224
21.41;SHELLOPTS;224
21.42;SHLVL;224
21.43;UID;225
21.44;BASH_ENV;225
21.45;CDPATH;225
21.46;COLUMNS;225
21.47;COMPREPLY;225
21.48;EMACS;225
21.49;FCEDIT;225
21.50;FIGNORE;226
21.51;GLOBIGNORE;226
21.52;HISTCONTROL;226
21.53;HISTFILE;226
21.54;HISTFILESIZE;226
21.55;HISTIGNORE;227
21.56;HISTSIZE;227
21.57;HISTTIMEFORMAT;227
21.58;HOME;227
21.59;HOSTFILE;227
21.60;IFS;228
21.61;IGNOREEOF;228
21.62;INPUTRC;228
21.63;LANG;228
21.64;LC_ALL;228
21.65;LC_COLLATE;228
21.66;LC_CTYPE;228
21.67;LC_MESSAGES;229
21.68;LC_NUMERIC;229
21.69;LINES;229
21.70;MAIL;229
21.71;MAILCHECK;229
21.72;MAILPATH;229
21.73;OPTERR;230
21.74;PATH;230
21.75;POSIXLY_CORRECT;230
21.76;PROMPT_COMMAND;230
21.77;PROMPT_DIRTRIM;230
21.78;PS1;230
21.79;PS2;231
21.80;PS3;231
21.81;PS4;231
21.82;SHELL;231
21.83;TIMEFORMAT;231
21.84;TMOUT;232
21.85;TMPDIR;232
21.86;auto_resume;232
21.87;histchars;232
22;Index;233




