
Linux Shell Scripting Cookbook.
Title:
Linux Shell Scripting Cookbook.
Author:
Tushar, Shantanu.
ISBN:
9781782162759
Personal Author:
Edition:
2nd ed.
Physical Description:
1 online resource (500 pages)
Contents:
Linux Shell Scripting Cookbook -- Table of Contents -- Linux Shell Scripting Cookbook -- Credits -- About the Authors -- About the Reviewers -- www.PacktPub.com -- Support files, eBooks, discount offers and more -- Why Subscribe? -- Free Access for Packt account holders -- Preface -- What this book covers -- What you need for this book -- Who this book is for -- Conventions -- Reader feedback -- Customer support -- Downloading the example code -- Errata -- Piracy -- Questions -- 1. Shell Something Out -- Introduction -- Printing in the terminal -- How to do it... -- How it works... -- There's more... -- Escaping newline in echo -- Printing a colored output -- Playing with variables and environment variables -- Getting ready -- How to do it... -- There's more... -- Finding the length of a string -- Identifying the current shell -- Checking for super user -- Modifying the Bash prompt string (username@hostname:~) -- Function to prepend to environment variables -- How to do it... -- How it works... -- Math with the shell -- Getting ready -- How to do it... -- Playing with file descriptors and redirection -- Getting ready -- How to do it... -- How it works... -- There's more... -- Redirection from a file to a command -- Redirecting from a text block enclosed within a script -- Custom file descriptors -- Arrays and associative arrays -- Getting ready -- How to do it... -- There's more... -- Defining associative arrays -- Listing of array indexes -- Visiting aliases -- How to do it... -- There's more... -- Escaping aliases -- Grabbing information about the terminal -- Getting ready -- How to do it... -- Getting and setting dates and delays -- Getting ready -- How to do it... -- How it works... -- There's more... -- Producing delays in a script -- Debugging the script -- How to do it... -- How it works... -- There's more... -- Shebang hack.
Functions and arguments -- How to do it... -- There's more... -- The recursive function -- Exporting functions -- Reading the return value (status) of a command -- Passing arguments to commands -- Reading the output of a sequence of commands in a variable -- Getting ready -- How to do it... -- There's more... -- Spawning a separate process with subshell -- Subshell quoting to preserve spacing and the newline character -- Reading n characters without pressing the return key -- How to do it... -- Running a command until it succeeds -- How to do it... -- How it works... -- There's more... -- A faster approach -- Adding a delay -- Field separators and iterators -- Getting ready -- How to do it... -- Comparisons and tests -- How to do it... -- 2. Have a Good Command -- Introduction -- Concatenating with cat -- How to do it... -- How it works… -- There's more... -- Getting rid of extra blank lines -- Displaying tabs as ^I -- Line numbers -- Recording and playing back of terminal sessions -- Getting ready -- How to do it... -- How it works... -- Finding files and file listing -- Getting ready -- How to do it... -- There's more... -- Search based on filename or regular expression match -- Negating arguments -- Search based on the directory depth -- Search based on file type -- Search on file times -- Search based on file size -- Deleting based on the file matches -- Match based on the file permissions and ownership -- Executing commands or actions with find -- Skipping specified directories when using the find command -- Playing with xargs -- Getting ready -- How to do it... -- How it works… -- There's more... -- Passing formatted arguments to a command by reading stdin -- Using xargs with find -- Counting the number of lines of C code in a source code directory -- While and subshell trick with stdin -- Translating with tr -- Getting ready -- How to do it...
How it works… -- There's more... -- Deleting characters using tr -- Complementing character set -- Squeezing characters with tr -- Character classes -- Checksum and verification -- Getting ready -- How to do it... -- How it works... -- There's more... -- Checksum for directories -- Cryptographic tools and hashes -- How to do it... -- Sorting unique and duplicates -- Getting ready -- How to do it... -- How it works… -- There's more... -- Sorting according to the keys or columns -- uniq -- Temporary file naming and random numbers -- How to do it... -- How it works… -- Splitting files and data -- How to do it... -- There's more… -- Specifying a filename prefix for the split files -- Slicing filenames based on extension -- How to do it… -- How it works… -- Renaming and moving files in bulk -- Getting ready -- How to do it... -- How it works… -- Spell checking and dictionary manipulation -- How to do it... -- How it works... -- Automating interactive input -- Getting ready -- How to do it... -- How it works… -- There's more... -- Automating with expect -- Making commands quicker by running parallel processes -- How to do it... -- How it works... -- 3. File In, File Out -- Introduction -- Generating files of any size -- How to do it... -- The intersection and set difference (A-B) on text files -- Getting ready -- How to do it... -- How it works... -- Finding and deleting duplicate files -- Getting ready -- How to do it... -- How it works... -- Working with file permissions, ownership, and the sticky bit -- How to do it... -- There's more... -- Changing ownership -- Setting sticky bit -- Applying permissions recursively to files -- Applying ownership recursively -- Running an executable as a different user (setuid) -- Making files immutable -- Getting ready -- How to do it... -- Generating blank files in bulk -- Getting ready -- How to do it...
Finding symbolic links and their targets -- How to do it... -- How it works... -- Enumerating file type statistics -- Getting ready -- How to do it... -- How it works... -- Using loopback files -- How to do it... -- How it works... -- There's more... -- Creating partitions inside loopback images -- Quicker way to mount loopback disk images with partitions -- Mounting ISO files as loopback -- Flush changing immediately with sync -- Creating ISO files and hybrid ISO -- Getting ready -- How to do it... -- There's more... -- Hybrid ISO that boots off a flash drive or hard disk -- Burning an ISO from the command line -- Playing with the CD-ROM tray -- Finding the difference between files, patching -- How to do it... -- There's more... -- Generating difference against directories -- Using head and tail for printing the last or first 10 lines -- How to do it... -- Listing only directories - alternative methods -- Getting ready -- How to do it... -- How it works... -- Fast command-line navigation using pushd and popd -- Getting ready -- How to do it... -- There's more... -- Most frequently used directory switching -- Counting the number of lines, words, and characters in a file -- How to do it... -- Printing the directory tree -- Getting ready -- How to do it... -- There's more... -- HTML output for tree -- 4. Texting and Driving -- Introduction -- Using regular expressions -- How to do it... -- How it works... -- There's more... -- Treatment of special characters -- Visualizing regular expressions -- Searching and mining a text inside a file with grep -- How to do it... -- There's more... -- Recursively search many files -- Ignoring case of pattern -- grep by matching multiple patterns -- Including and excluding files in a grep search -- Using grep with xargs with zero-byte suffix -- Silent output for grep -- Printing lines before and after text matches.
Cutting a file column-wise with cut -- How to do it... -- There's more -- Specifying the range of characters or bytes as fields -- Using sed to perform text replacement -- How to do it… -- There's more... -- Removing blank lines -- Performing replacement directly in the file -- Matched string notation (&) -- Substring match notation (\1) -- Combination of multiple expressions -- Quoting -- Using awk for advanced text processing -- Getting ready... -- How to do it… -- How it works… -- There's more… -- Special variables -- Passing an external variable to awk -- Reading a line explicitly using getline -- Filtering lines processed by awk with filter patterns -- Setting delimiter for fields -- Reading the command output from awk -- Using loop inside awk -- String manipulation functions in awk -- Finding the frequency of words used in a given file -- Getting ready -- How to do it... -- How it works... -- See also -- Compressing or decompressing JavaScript -- Getting ready -- How to do it... -- How it works... -- See also -- Merging multiple files as columns -- How to do it... -- See also -- Printing the nth word or column in a file or line -- How to do it... -- See also -- Printing text between line numbers or patterns -- Getting ready -- How to do it... -- See also -- Printing lines in the reverse order -- Getting ready -- How to do it... -- How it works... -- Parsing e-mail addresses and URLs from text -- How to do it... -- How it works... -- See also -- Removing a sentence in a file containing a word -- Getting ready -- How to do it... -- How it works... -- See also -- Replacing a pattern with text in all the files in a directory -- How to do it... -- How it works... -- There's more... -- Text slicing and parameter operations -- How to do it... -- See also -- 5. Tangled Web? Not At All! -- Introduction -- Downloading from a web page -- Getting ready.
How to do it...
Abstract:
This book is written in a Cookbook style and it offers learning through recipes with examples and illustrations. Each recipe contains step-by-step instructions about everything necessary to execute a particular task. The book is designed so that you can read it from start to end for beginners, or just open up any chapter and start following the recipes as a reference for advanced users.If you are a beginner or an intermediate user who wants to master the skill of quickly writing scripts to perform various tasks without reading the entire manual, this book is for you. 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.
Local Note:
Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2017. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.
Genre:
Electronic Access:
Click to View