Book Image

Linux Command Line and Shell Scripting Bible - Third Edition

By : Richard Blum, Christine Bresnahan
Book Image

Linux Command Line and Shell Scripting Bible - Third Edition

By: Richard Blum, Christine Bresnahan

Overview of this book

The Linux command line enables you to type specific shell commands directly into the system to manipulate files and query system resources. Command line statements can be combined into short programs called shell scripts, a practice increasing in popularity due to its usefulness in automation. Linux is a robust system with tremendous potential, and Linux Command Line and Shell Scripting Bible opens the door to new possibilities. Linux Command Line and Shell Scripting Bible is your essential Linux guide. It contains new functional examples that are fully updated to align with the latest Linux features. Beginning with command line fundamentals, the book moves into shell scripting and shows you the practical application of commands in automating frequently performed functions. This book is a complete guide providing detailed instruction and expert advice working within this aspect of Linux. Whether used as a tutorial or as a quick reference, this book contains information that every Linux user should know.
Table of Contents (34 chapters)
2
Part I: The Linux Command Line
13
Part II: Shell Scripting Basics
20
Part III: Advanced Shell Scripting
28
Part IV: Creating Practical Scripts
32
End User License Agreement

Scripting with zsh

The main purpose of the zsh shell was to provide an advanced programming environment for shell programmers. With that in mind, it's no surprise that the zsh shell offers many features that make shell scripting easier.

Mathematical operations

As you would expect, the zsh shell allows you to perform mathematical functions with ease. In the past, the Korn shell has led the way in supporting mathematical operations by providing support for floating-point numbers. The zsh shell has full support for floating-point numbers in all its mathematical operations!

Performing calculations

The zsh shell supports two methods for performing mathematical operations:

  • The let command
  • Double parentheses

When you use the let command, you should enclose the operation in double quotation marks to allow for spaces:

% let value1=" 4 * 5.1 / 3.2 "
% echo $value1
6.3750000000
%

Be careful, using floating point numbers may introduce a precision problem. To solve this, it&apos...