Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Bash Quick Start Guide

You're reading from   Bash Quick Start Guide Get up and running with shell scripting with Bash

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781789538830
Length 186 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Tom Ryder Tom Ryder
Author Profile Icon Tom Ryder
Tom Ryder
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. What is Bash? FREE CHAPTER 2. Bash Command Structure 3. Essential Commands 4. Input, Output, and Redirection 5. Variables and Patterns 6. Loops and Conditionals 7. Scripts, Functions, and Aliases 8. Best Practices 9. Other Books You May Enjoy

Choosing when to apply Bash

There are some tasks for which shell scripting in general, and Bash in particular, are especially well-suited:

  • Prototyping: Short Bash programs are quick and easy to write. It's quite common to "hack together" a simple script in Bash for later replacement by a script or program in a more advanced programming language that requires more effort to write and maintain.

  • Interactive system administration: A Bourne-style shell is assumed in very many contexts in Unix, and almost all of the system documentation you read will tell you to issue commands in a Bourne-style shell. This makes it a natural choice for a scripting language.

  • Automation: If you have a set of commands you often run together, making a script for them is as simple as writing them all into a text file, each on a new line, and making that file executable.

  • Connecting programs together: Like all Shell scripting languages, Bash specializes in moving data to and from files and between processes. Many programs are designed to work together in this way.

  • Filtering and transforming text input: Some programs, however, aren't designed to cooperate in this way, and they require some data filtering and transformation in the middle. Bash can be a very convenient language for doing this, and it's also a good language to call other tools such as awk or sed to do it for you.

  • Navigating the Unix filesystem: In Bash, it does not require much code to navigate and iterate through the filesystem, discovering, filtering, and processing files within it at runtime. Coupled with the find tool, especially a high-powered version such as GNU find, a lot can be done in a pattern over a filesystem with relatively little code.

  • Basic pattern-matching on strings: Bash has features that make it good for basic pattern-matching on strings, especially filenames and path names, with parameter expansion.

  • Portability: Bash works on and is packaged for a huge variety of Unix-like systems. POSIX shell script is even more widely supported. If you need to know your script and its runtime will remain portable to many Unix-like systems, Bash might be a good choice.

You have been reading a chapter from
Bash Quick Start Guide
Published in: Sep 2018
Publisher: Packt
ISBN-13: 9781789538830
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image