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
Working with Linux ??? Quick Hacks for the Command Line

You're reading from   Working with Linux ??? Quick Hacks for the Command Line Command line power like you've never seen

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781787129184
Length 222 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Bogdan Vaida Bogdan Vaida
Author Profile Icon Bogdan Vaida
Bogdan Vaida
Petru I»ôfan Petru I»ôfan
Author Profile Icon Petru I»ôfan
Petru I»ôfan
Arrow right icon
View More author details
Toc

Shell scripting for fun and profit

Pipes and subshells are one way of expanding the capabilities of our shell. The ultimate way is by writing shell scripts. These scenarios must be taken into consideration when dealing with complex tasks that can't be automated with a one-line command.

The good news is that almost all the tasks can be automated with the use of shell scripts. We won't go over an introduction to shell scripts. Instead, we will be looking at some more advanced use cases for writing them.

Let's start our journey into shell scripting! First thing, let's open a file called script.sh and split the screen so that we can test while writing. Every shell should start with #!, followed by the interpreter it uses. This line is called a shebang. We will be using bash as our default interpreter.

It's a good idea to use bash, because it's a common interpreter that comes with most Linux distributions and also OS X:

#!/bin/bash

Let's start with a simple use...

You have been reading a chapter from
Working with Linux ??? Quick Hacks for the Command Line
Published in: May 2017
Publisher: Packt
ISBN-13: 9781787129184
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