Skip to Content
Python for Unix and Linux System Administration
book

Python for Unix and Linux System Administration

by Noah Gift, Jeremy M. Jones
August 2008
Intermediate to advanced content levelIntermediate to advanced
458 pages
12h 47m
English
O'Reilly Media, Inc.
Content preview from Python for Unix and Linux System Administration

Chapter 3. Text

Nearly every system administrator has to deal with text whether it is in the form of logfiles, application data, XML, HTML, configuration files, or the output of some command. Often, utilities like grep and awk are all you need, but sometimes a tool that is more expressive and elegant is needed to tackle complex problems. When you need to create files with data extracted from other files, redirecting text from the output of a process (again, grep and awk come to mind) to a file is often good enough. But there are also times when a tool that is more easily extensible is better-suited for the job.

As we explained in the Introduction,” our experience has shown that that Python qualifies as more elegant, expressive, and extensible than Perl, Bash, or other languages we have used for programming. For more discussion of why we value Python more highly than Perl or Bash (and you could make application to sed and awk), see Chapter 1. Python’s standard library, language features, and built-in types are powerful tools for reading text files, manipulating text, and extracting information from text files. Python and its standard library contain a wealth of flexibility and functionality for text processing using the string type, the file type, and the regular expression module. A recent addition to the standard library, ElementTree, is immensely helpful when you need to work with XML. In this chapter, we will show you how to effectively use the standard library and built-in components ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Fundamentals

Linux Fundamentals

Sander van Vugt
UNIX and Linux System Administration Handbook, 5th Edition

UNIX and Linux System Administration Handbook, 5th Edition

Trent R. Hein, Evi Nemeth, Garth Snyder, Ben Whaley, Dan Mackin

Publisher Resources

ISBN: 9780596515829Supplemental ContentErrata Page