Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Linux Shell Scripting Cookbook, Second Edition
Linux Shell Scripting Cookbook, Second Edition

Linux Shell Scripting Cookbook, Second Edition: Don't neglect the shell – this book will empower you to use simple commands to perform complex tasks. Whether you're a casual or advanced Linux user, the cookbook approach makes it all so brilliantly accessible and, above all, useful. , Second Edition

eBook
€8.99 €28.99
Paperback
€37.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Linux Shell Scripting Cookbook, Second Edition

Chapter 2. Have a Good Command

In this chapter, we will cover:

  • Concatenating with cat

  • Recording and playingback of terminal sessions

  • Finding files and file listing

  • Playing with xargs

  • Translating with tr

  • Checksum and verification

  • Cryptographic tools and hashes

  • Sorting unique and duplicates

  • Temporary file naming and random numbers

  • Splitting files and data

  • Slicing filenames based on extension

  • Renaming and moving files in bulk

  • Spell checking and dictionary manipulation

  • Automating interactive input

  • Making commands quicker by running parallel processes

Introduction


Unix-like systems have the privilege of having the best command-line tools. They help us achieve many tasks making our work easier. While each command has a specific focus, with practice you'll be able to solve complex problems by combining two or more commands. Some frequently used commands are grep, awk, sed, and find.

Mastering the Unix/Linux command line is an art; you will get better at using it as you practice and gain experience. This chapter will introduce you to some of the most interesting and useful commands.

Concatenating with cat


cat is one of the first commands that a command-line warrior must learn. It is usually used to read, display, or concatenate the contents of a file, but cat is capable of more than just that. We even scratch our heads when we need to combine standard input data, as well as data from a file using a single-line command. The regular way of combining the stdin data, as well as file data, is to redirect stdin to a file and then append two files. But we can use the cat command to do it easily in a single invocation. In this recipe we will see basic and advanced usages of cat.

How to do it...

The cat command is a very simple and frequently used command and it stands for concatenate.

The general syntax of cat for reading contents is:

$ cat file1 file2 file3 ...

This command concatenates data from the files specified as command-line arguments.

  • To print contents of a single file:

    $ cat file.txt
    This is a line inside file.txt
    This is the second line inside file.txt
    
  • To print contents...

Recording and playing back of terminal sessions


When you need to show somebody how to do something in the terminal, or you need to prepare a tutorial on how to do something through the command line, you would normally type the commands manually and show them. Or, you could record a screencast and playback the video to them. There are other options for doing this. Using the commands script and scriptreplay, we can record the order and timing of the commands and save the data to text files. Using these files, others can replay and see the output of the commands on the terminal until the playback is complete.

Getting ready

The script and scriptreplay commands are available in most of the GNU/Linux distributions. Recording the terminal sessions to a file will be interesting. You can create tutorials of command-line hacks and tricks to achieve a task by recording the terminal sessions. You can also share the recorded files for others to playback and see how to perform a particular task using...

Finding files and file listing


find is one of the great utilities in the Unix/Linux command-line toolbox. It is a very useful command for shell scripts; however, many people do not use it to its fullest effectiveness. This recipe deals with most of the common ways to utilize find to locate files.

Getting ready

The find command uses the following strategy: find descends through a hierarchy of files, matches the files that meet specified criteria, and performs some actions. Let's go through different use cases of find and its basic usages.

How to do it...

To list all the files and folders from the current directory to the descending child directories, use the following syntax:

$ find base_path

base_path can be any location from which find should start descending (for example, /home/slynux/).

An example of this command is as follows:

$ find . -print
# Print lists of files and folders

. specifies current directory and .. specifies the parent directory. This convention is followed throughout the Unix...

Playing with xargs


We use pipes to redirect stdout (standard output) of a command to stdin (standard input) of another command. For example:

cat foo.txt | grep "test"

Some of the commands accept data as command-line arguments rather than a data stream through stdin (standard input). In that case, we cannot use pipes to supply data through command-line arguments.

We should try alternate methods. xargs is a command that is very helpful in handling standard input data to the command-line argument conversions. It can manipulate stdin and convert to command-line arguments for the specified command. Also, xargs can convert any one-line or multiple-line text inputs into other formats, such as multiple lines (specified number of columns) or a single line and vice versa.

All Bash users love one-liner commands, which are command sequences that are joined by using the pipe operator, but do not use the semicolon terminator (;) between the commands used. Crafting one-line commands makes tasks more efficient...

Translating with tr


tr is a small and beautiful command in the Unix command-warrior toolkit. It is one of the important commands frequently used to craft beautiful one-liner commands. It can be used to perform substitution of characters, deletion of the characters, and squeezing of repeated characters from the standard input. It is often called translate , since it can translate a set of characters to another set. In this recipe we will see how to use tr to perform basic translation between sets.

Getting ready

tr accepts input only through stdin (standard input) and cannot accept input through command-line arguments. It has the following invocation format:

tr [options] set1 set2

Input characters from stdin are mapped from set1 to set2 and the output is written to stdout (standard output). set1 and set2 are character classes or a set of characters. If the length of sets is unequal, set2 is extended to the length of set1 by repeating the last character, or else, if the length of set2 is greater...

Checksum and verification


Checksum programs are used to generate checksum key strings from the files and verify the integrity of the files later by using that checksum string. A file might be distributed over the network or any storage media to different destinations. Due to many reasons, there are chances of the file being corrupted due to a few bits missing during the data transfer by different reasons. These errors happen most often while downloading the files from the Internet, transferring through a network, CD-ROM damage, and so on.

Hence, we need to know whether the received file is the correct one or not by applying some kind of test. The special key string that is used for this file integrity test is known as a checksum.

We calculate the checksum for the original file as well as the received file. By comparing both of the checksums, we can verify whether the received file is the correct one or not. If the checksums (calculated from the original file at the source location and the...

Cryptographic tools and hashes


Encryption techniques are used mainly to protect data from unauthorized access. There are many algorithms available and we have discussed the most commonly used ones. There are a few tools available in a Linux environment for performing encryption and decryption. Sometimes we use encryption algorithm hashes for verifying data integrity. This section will introduce a few commonly used cryptographic tools and a general set of algorithms that these tools can handle.

How to do it...

Let us see how to use tools such as crypt, gpg, base64, md5sum, sha1sum, and openssl:

  • The crypt command is a simple and relatively insecure cryptographic utility that takes a file from stdin and a passphrase as input and output encrypted data into stdout (and, hence, we use redirection for the input and output files):

    $ crypt <input_file >output_file
    Enter passphrase:
    

    It will interactively ask for a passphrase. We can also provide a passphrase through command-line arguments:

    $ crypt...

Sorting unique and duplicates


Sorting is a common task that we can encounter with text files. The sort command helps us to perform sort operations over text files and stdin. Most often, it can also be coupled with many other commands to produce the required output. uniq is another command that is often used along with a sort command. It helps to extract unique (or duplicate) lines from a text or stdin. This recipe illustrates most of the use cases with sort and uniq commands.

Getting ready

The sort command accepts input as filenames, as well as from stdin (standard input) and outputs the result by writing into stdout. The same applies to the uniq command.

How to do it...

  1. We can easily sort a given set of files (for example, file1.txt and file2.txt) as follows:

    $ sort file1.txt file2.txt > sorted.txt
    

    Or:

    $ sort file1.txt file2.txt -o sorted.txt
    
  2. For a numerical sort, we can use:

    $ sort -n file.txt
    
  3. To sort in the reverse order, we can use:

    $ sort -r file.txt
    
  4. For sorting by months (in the order...

Temporary file naming and random numbers


While writing shell scripts, we often need to store temporary data. The most suitable location to store temporary data is /tmp (which will be cleaned out by the system on reboot). We can use two methods to generate standard filenames for temporary data.

How to do it...

Perform the following steps to create a temporary file and perform different naming operations on it:

  1. Create a temporary file as follows:

    $ filename=`mktemp`
    $ echo $filename
    /tmp/tmp.8xvhkjF5fH
    

    This will create a temporary file and print its filename which we store in $filename in this example.

  2. To create a temporary directory, use the following commands:

    $ dirname=`mktemp -d`
    $ echo $dirname
    tmp.NI8xzW7VRX
    

    This will create a temporary directory and print its filename which we store in $dirname in this example.

  3. To just generate a filename without actually creating a file or directory, use this:

    $ tmpfile=`mktemp -u`
    $ echo $tmpfile
    /tmp/tmp.RsGmilRpcT
    

    Here, the filename will be stored in...

Splitting files and data


Splitting of files into many smaller pieces becomes essential in certain situations. Earlier, when memory was limited with devices such as floppy disks, it was crucial to split files into smaller file sizes to split files across many disks. However, nowadays we split files for other purposes, such as readability, for generating logs, sending files over e-mail, and so on. In this recipe we will see various ways of splitting files in different chunks.

How to do it...

Let's say we have a test file called data.file, which has a size of 100 KB. You can split this file into smaller files of 10k each by specifying the split size as follows:

$ split -b 10k data.file
$ ls
data.file  xaa  xab  xac  xad  xae  xaf  xag  xah  xai  xaj

It will split data.file into many files, each of a 10k chunk. The chunks will be named the manner xab, xac, xad, and so on. This means it will have alphabetic suffixes. To use the numeric suffixes, use an additional -d argument. It is also possible...

Slicing filenames based on extension


Several shell scripts perform manipulations based on filenames. We may need to perform actions such as renaming the files by preserving the extension, converting files from one format to another (change the extension by preserving the name), extracting a portion of the filename, and so on. The shell comes with inbuilt features for slicing filenames based on different conditions. Let us see how to do it.

How to do it…

The name from name.extension can be easily extracted using the % operator. You can extract the name from "sample.jpg" as follows:

file_jpg="sample.jpg"
name=${file_jpg%.*}
echo File name is: $name

The output is:

File name is: sample

The next task is to extract the extension of a file from its filename. The extension can be extracted using the # operator as follows:

Extract .jpg from the filename stored in the variable file_jpg as follows:

extension=${file_jpg#*.}
echo Extension is: jpg

The output is:

Extension is: jpg

How it works…

In the first task...

Renaming and moving files in bulk


Renaming a number of files is one of the tasks we frequently come across. A simple example is when you download photos from your digital camera to your computer you may delete unnecessary files and it causes discontinuous numbering of image files. Sometimes, you may need to rename them with a custom prefix and continuous numbering for filenames. We sometimes use third-party tools for performing rename operations. We can use Bash commands to perform a rename operation in a couple of seconds.

Moving all the files having a particular substring in their filenames (for example, the same prefix for filenames) or with a specific file type to a given directory is another use case we frequently perform. Let's see how to write scripts to perform these kinds of operations.

Getting ready

The rename command helps to change filenames using Perl regular expressions. By combining the commands find, rename, and mv, we can perform a lot of things.

How to do it...

The easiest way...

Spell checking and dictionary manipulation


Most of the Linux distributions come with a dictionary file along with them. However, I find very few people to be aware of the dictionary file and hence, few make use of them. There is a command-line utility called aspell that functions as a spell checker. Let's go through a few scripts that make use of the dictionary file and the spell checker.

How to do it...

The /usr/share/dict/ directory contains some of the dictionary files. Dictionary files are text files that contain a list of dictionary words. We can use this list to check whether a word is a dictionary word or not.

$ ls /usr/share/dict/ 
american-english  british-english

To check whether the given word is a dictionary word, use the following script:

#!/bin/bash
#Filename: checkword.sh
word=$1
grep "^$1$" /usr/share/dict/british-english -q 
if [ $? -eq 0 ]; then
  echo $word is a dictionary word;
else
  echo $word is not a dictionary word;
fi

The usage is as follows:

$ ./checkword.sh ful ...

Automating interactive input


Automating interactive input for command-line utilities are extremely useful for writing automation tools or testing tools. There will be many situations when we deal with commands that read input interactively. An example of executing a command and supplying the interactive input is as follows:

$ command
Enter a number: 1
Enter name : hello
You have entered 1,hello

Getting ready

Creating utilities that can automate the acceptance of input are useful to supply input to local commands, as well as for remote applications. Let us see how to automate them.

How to do it...

Think about the sequence of an interactive input. From the previous code, we can formulate the steps of the sequence as follows:

1[Return]hello[Return]

Converting the preceding steps 1, Return, hello, and Return by observing the characters that are actually typed in the keyboard, we can formulate the following string:

"1\nhello\n"

The \n character is sent when we press return. By appending the return...

Making commands quicker by running parallel processes


Computing power has increased a lot over the last couple of years. However, this is not just because of having processors with higher clock cycles; the thing that makes modern processors faster is multiple cores. What this means to the user is in a single hardware processor there are multiple logical processors.

However, the multiple cores are useless unless the software makes use of them. For example, if you have a program that does huge calculations, it will only run on one of the cores, the others will sit idle. The software has to be aware and take advantage of the multiple cores if we want it to be faster.

In this recipe we will see how we can make our commands run faster.

How to do it...

Let us take an example of the md5sum command that we discussed in the previous recipes. This command is CPU-intensive as it has to perform the calculation. Now, if we have more than one file that we want to generate a checksum of, we can run multiple...

Left arrow icon Right arrow icon

Key benefits

  • Master the art of crafting one-liner command sequence to perform text processing, digging data from files, backups to sysadmin tools, and a lot more
  • And if powerful text processing isn't enough, see how to make your scripts interact with the web-services like Twitter, Gmail
  • Explores the possibilities with the shell in a simple and elegant way - you will see how to effectively solve problems in your day to day life

Description

The shell remains one of the most powerful tools on a computer system — yet a large number of users are unaware of how much one can accomplish with it. Using a combination of simple commands, we will see how to solve complex problems in day to day computer usage.Linux Shell Scripting Cookbook, Second Edition will take you through useful real-world recipes designed to make your daily life easy when working with the shell. The book shows the reader how to effectively use the shell to accomplish complex tasks with ease.The book discusses basics of using the shell, general commands and proceeds to show the reader how to use them to perform complex tasks with ease.Starting with the basics of the shell, we will learn simple commands with their usages allowing us to perform operations on files of different kind. The book then proceeds to explain text processing, web interaction and concludes with backups, monitoring and other sysadmin tasks.Linux Shell Scripting Cookbook, Second Edition serves as an excellent guide to solving day to day problems using the shell and few powerful commands together to create solutions.

Who is this book for?

This book is both for the casual GNU/Linux users who want to do amazing things with the shell, and for advanced users looking for ways to make their lives with the shell more productive.You can start writing scripts and one-liners by simply looking at the similar recipe and its descriptions without any working knowledge of shell scripting or Linux. Intermediate/advanced users as well as system administrators/ developers and programmers can use this book as a reference when they face problems while coding.

What you will learn

  • Explore a variety of regular usage tasks and how it can be made faster using shell command
  • Write shell scripts that can dig data from web and process it with few lines of code
  • Use different kinds of tools together to create solutions
  • Interact with simple web API from scripts
  • Perform and automate tasks such as automating backups and restore with archiving tools
  • Create and maintain file/folder archives, compression formats and encrypting techniques with shell
  • Set up Ethernet and Wireless LAN with the shell script
  • Monitor different activities on the network using logging techniques
Estimated delivery fee Deliver to Finland

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 21, 2013
Length: 384 pages
Edition : 2nd
Language : English
ISBN-13 : 9781782162742
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Finland

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : May 21, 2013
Length: 384 pages
Edition : 2nd
Language : English
ISBN-13 : 9781782162742
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 121.97
Web Penetration Testing with Kali Linux
€41.99
Linux Shell Scripting Cookbook, Second Edition
€37.99
CentOS 6 Linux Server Cookbook
€41.99
Total 121.97 Stars icon
Banner background image

Table of Contents

9 Chapters
Shell Something Out Chevron down icon Chevron up icon
Have a Good Command Chevron down icon Chevron up icon
File In, File Out Chevron down icon Chevron up icon
Texting and Driving Chevron down icon Chevron up icon
Tangled Web? Not At All! Chevron down icon Chevron up icon
The Backup Plan Chevron down icon Chevron up icon
The Old-boy Network Chevron down icon Chevron up icon
Put on the Monitor's Cap Chevron down icon Chevron up icon
Administration Calls Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(9 Ratings)
5 star 77.8%
4 star 0%
3 star 0%
2 star 22.2%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Pierre Jun 23, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have started using Linux in 2000 with Suse Linux. Coming from Windows Linux right away took my interest especially the tremendous freedom it gives you and the ability to operate the system instead of being operated by the system. But if you want to get into the depth of Linux and being an expert the learning curve especially when starting is quite steep and the huge amount of possibilities is hard to tackle. But if you go over this hurdle than you get rewarded with the knowledge of how to rule your computer. You can do it the hard way as I did when starting with Linux by asking Google for each and every question coming up. But if you want to accelerate to get into understanding and using Linux not only on the surface than this book is for you.The book is precisely focused on shell scripting and is therefore always right to the point. So you won't find information on how to install Linux but as this is one of the easier parts you can find a lot of good information on the internet and nowadays setting up a Linux machine is quite easy.If you have Linux installed this book helps you to jump right into the topic. In the introduction of chapter 1 you get the basics about the shell environment you need just enough to start scripting. For example it is explained what does the prompt look like, the structure of a shell script and how to start it. And some handy information to avoid unnecessary typing using the history.After the introduction of each chapter the book starts with recipes. Each recipe is introduced with a short objective of a recipe and then it has more or less always the same structure. Getting ready gives a brief overview of the commands and syntax used in the following sections. How to do it shows how the commands are used that support the objective. The explanation is done on practical and real life examples that can be used in your day to day work. In some recipes you get also deeper information in the But there is more section that can be skipped at a first read and referenced later when topic comes up in combination with other recipes.As this book's title denotes the content is presented as a cookbook. In a cookbook you can assume to jump into a specific topic and than just program along. But I would recommend before starting to read the first chapter as it explains all basic elements of a shell script like variable assignment, arrays, functions and other programming structures as well as debugging tools and strategies. After chapter 1 you have enough information to tackle the recipes in following chapters.Chapter 2 and chapter 3 provide a comprehensive set of recipes on file manipulation. Chapter 2 is more focused on recipes you will need in your day to day work, like finding, copying and moving files. Chapter 3 has more sophisticated recipes like file comparison to find out the differences between two files.Chapter 4 is about the content of files, that is finding and manipulating the content of a file. The chapter starts with an introduction into regular expressions and some often used patterns like e-mail address validation are provided.Especially interesting to me was chapter 5 which goes beyond the Linux operating system but shows how to use shell scripting for accessing the web. I liked the recipe about cURL, a very sophisticated and comprehensive tool for accessing the web through a lot of different web protocols. This recipe gives you a kick start into cURL with the commands you will use 80% of your time when down or uploading files from or to the web or another file system.The book does not only cover topics you would need as a regular Linux user but also provides recipes for administration tasks. And from my experience the book covers the main commands that you would need to administer your private Linux home network to keep it up and running. The chapters 6, 8 and 9 cover backup tools, tools for monitoring you system and manipulating or running automatically scheduled processes with cron jobs.And finally chapter 7 has a lot to say about setting up a network. The topics cover file transfer between computers or logging in to remote computers using ssh.If you are a programmer of a programming language that uses a lot the Linux shell like Python, Ruby or Ruby on Rails than I also can recommend this book. It covers the topics you will need when mainly working with the console and not using an IDE. Especially useful I consider in this regard the topics how to find files, how to compare files, how to find a specific content of a file that you need to refactor. SSH without login is also very useful when working with Ruby on Rails and administrating an application server like passenger. Also the brief introduction into Git serves as a good start into managing and archiving your source files like the scripts you generate based on the knowledge gained from the book. The section finding broken links on a web site is very helpful when working as a web developer.So all in all this book is a very helpful companion whether you are using Linux as a regular user or as an administrator. And if you are a developer you find a lot of valuable commands and recipes that make your programming life easier. It is a book you should have handy when you are one of the above mentioned users to make your life easier with Linux.
Amazon Verified review Amazon
T. Williams Mar 19, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is one of the best books I have read on Linux scripting. Shantanu, has a straight to the point no fluff writing style. It was straight forward and I was able to read this book in two days because of it. It felt good not having to waste my time with page "filler's" as I have done with most technical books. I commend Shantanu on his efforts and I hope that other ( IT) technical writers take note.
Amazon Verified review Amazon
Doug Duncan Oct 10, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Linux Shell Scripting Cookbook by Shantanu Tushar and Sarath Lakshman is a book that will get beginners of the Linux shell up to speed quickly. Being a cookbook style book a user can bounce around pretty much at will to get their task completed without relying on having read previous recipes.The reader will find basic admin type one-liners, in addition to some interesting recipes such as how to access your gmail account and sending tweets from the command line.Overall this is a well written book and something every beginning Linux admin (or power user) will want to have in their collection.
Amazon Verified review Amazon
Gregory T. Laden Oct 07, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I just finished "Linux Shell Scripting Cookbook" (Second Edition) by Shantanu Tushar and Sarath Lakshman. This is a beginner's guide to using shell scripting (bash) on linux.Usually, a "cookbook" is set up more like a series of projects organized around a set of themes, and is usually less introductory than this book. "Linux Shell Scripting Cookbook" might be better titled "Introduction to Linux Shell Scripting" because it is more like a tutorial and a how too book than like a cookbook. Nonetheless, it is an excellent tutorial that includes over 100 "recipes" that address a diversity of applications. It's just that they are organized more like a tutorial. What this means is that a beginner can use only the resources in this book and get results. The various recipes are organized in an order that brings the reader through basics (like how to use the terminal, how to mess with environment variables, etc.) then on to more complex topics such as regular expressions, manipulating text, accessing web pages, and archiving. One very nice set of scripts that is not often found in intro books addresses networking. The book also covers MySQL database use.All of the scripts are available from the publisher in a well organized zip archive.I read the e-version of the book, in iBooks, but the PDF version is very nice as well. I don't know how this would translate as at Kindle book. But, importantly (and this may be more common now than not) the ebook uses all text, unlike some earlier versions of ebooks that used photographs of key text snippets as graphics which essentially renders them useless. Of course, copy and paste from a ebook is difficult, and that is where the zip file of scrips comes in. You can open the PDF file, get the zip archive, and as you read through examples simply open up (or copy and paste) the scripts from the zip archive and modify or run them. Also, the ebook is cheaper than a paper edition and clearly takes up way less space!If I was going to recommend a starting out guide to shell scripting this is the book I'd recommend right now. It is well organized and well executed.
Amazon Verified review Amazon
Amazon Customer Apr 27, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is one of the best Linux books I've studied in the last year - and i've studied several. This book will give you the hacker buzz. If you have had at least some exposure to Linux, and want a better understanding of the command line and shell scripting in particular, then get this book!I had my doubts, but the first two chapters are pure gold. And there's one teasure after another throughout the whole book. Absolutely insightful...and it makes a perfect reference for looking up various commands and getting the essential information on how to use them quickly, showing things by example. Commands like "xargs" have never been presented in a meaningful way to me before; the authors do this for all the essential commands.And along the way, shell scripting will just sneaks in there. Before you know it, you're jamming! Fantastic treatment on a variety of topics that anyone with a computer background will recognize and can leverage or exploit...potentially, of course. The more background you have with Linux, the more you'll love this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela