Linux shell scripting cookbook over 110 incredibly effective recipes to solve real-world problems, automate tedious tasks, and take advantage of Linux's newest features

Do amazing things with the shell About This Book Become an expert in creating powerful shell scripts and explore the full possibilities of the shell Automate any administrative task you could imagine, with shell scripts Packed with easy-to-follow recipes on new features on Linux, particularly, Debia...

Descripción completa

Detalles Bibliográficos
Otros Autores: Flynt, Clif, author (author), Tushar, Shantanu, author, Lakshman, Sarath, author
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham, UK : Packt Publishing 2017.
Edición:Third edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630219206719
Tabla de Contenidos:
  • Cover
  • Copyright
  • Credits
  • About the Authors
  • About the Reviewer
  • www.PacktPub.com
  • Customer Feedback
  • Table of Contents
  • Preface
  • Chapter 1: Shell Something Out
  • Introduction
  • Displaying output in a terminal
  • Getting ready
  • How to do it...
  • How it works...
  • There's more...
  • Escaping newline in echo
  • Printing a colored output
  • Using 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
  • 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
  • Listing 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
  • Reading the return value (status) of a command
  • Passing arguments to commands
  • Sending output from one command to another
  • 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...
  • Customizing bash with configuration files
  • How to do it...
  • Chapter 2: Have a Good Command
  • Introduction
  • Concatenating with cat
  • How to do it...
  • There's more...
  • Getting rid of extra blank lines
  • Displaying tabs as ^I
  • Line numbers
  • Recording and playing back 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 name or regular expression match
  • Negating arguments
  • Searching based on the directory depth
  • Searching based on file type
  • Searching by file timestamp
  • Searching based on file size
  • Matching based on file permissions and ownership
  • Performing actions on files with find
  • Deleting based on file matches
  • Executing a command
  • 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 sets
  • 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 duplicate lines
  • Getting ready
  • How to do it...
  • How it works...
  • There's more...
  • Sorting according to 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 extensions
  • 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...
  • There's more...
  • Examining a directory, files and subdirectories in it
  • Getting ready
  • How to do it...
  • Generating a tree view of a directory.
  • Generating a summary of files and sub-directories
  • Chapter 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 the 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
  • Mounting loopback disk images with partitions more quickly
  • 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, and 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...
  • pushd and popd are useful when there are more than three directory paths used. However, when you use only two locations, there is an alternative and easier way, that is, cd -.
  • 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
  • Manipulating video and image files
  • Getting ready
  • Extracting Audio from a movie file (mp4)
  • How to do it...
  • Making a video from a set of still images
  • How to do it...
  • How it works...
  • Creating a panned video from a still camera shot
  • How to do it...
  • How it works...
  • Chapter 4: Texting and Driving
  • Introduction
  • Using regular expressions
  • How to do it...
  • Position markers
  • Identifiers.
  • Count modifiers
  • Other
  • There's more...
  • How it works...
  • There's more...
  • Treatment of special characters
  • Visualizing regular expressions
  • Searching and mining text inside a file with grep
  • How to do it...
  • There's more...
  • Recursively searching many files
  • Ignoring case in patterns
  • grep by matching multiple patterns
  • Including and excluding files in a grep search
  • Using grep with xargs with the 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)
  • Combining 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 delimiters for fields
  • Reading the command output from awk
  • Associative arrays in 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.