Bash Cookbook: Solutions And Examples For Bash Users

Preparing link to download Please wait... Attached file not found

E-Book Overview

For system administrators, programmers, and end users, shell command or carefully crafted shell script can save you time and effort, or facilitate consistency and repeatability for a variety of common tasks. This cookbook provides more than 300 practical recipes for using bash, the popular Unix shell that enables you to harness and customize the power of any Unix or Linux system.

Ideal for new and experienced users alike—including proficient Windows users and sysadmins—this updated second edition helps you solve a wide range of problems. You’ll learn ways to handle input/output, file manipulation, program execution, administrative tasks, and many other challenges. Each recipe includes one or more scripting examples and a discussion of why the solution works.

You’ll find recipes for problems including:

  • Standard output and input, and executing commands
  • Shell variables, shell logic, and arithmetic
  • Intermediate shell tools and advanced scripting
  • Searching for files with find, locate, and slocate
  • Working with dates and times
  • Creating shell scripts for various end-user tasks
  • Working with tasks that require parsing
  • Writing secure shell scripts
  • Configuring and customizing bash

E-Book Content

bash Cookbook SECOND EDITION Solutions and Examples for bash Users Carl Albing and JP Vossen 2 bash Cookbook by Carl Albing and JP Vossen Copyright © 2018 Carl Albing and JP Vossen. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected] Editor: Jeff Bleiel Production Editor: Kristen Brown Copyeditor: Rachel Head Proofreader: James Fraleigh Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest May 2007: First Edition October 2017: Second Edition Revision History for the Second Edition 2017-10-04: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491975336 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. bash Cookbook, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the 3 publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-491-97533-6 [LSI] 4 Preface Every modern operating system has at least one shell, and some have many. Some shells are command line–oriented, such as the shell discussed in this book. Others are graphical, like Windows Explorer or the Macintosh Finder. Some users will interact with the shell only long enough to launch their favorite application, and then never emerge from that until they log off. But most users spend a significant amount of time using the shell. The more you k