Skip to Main Content
Linux System Administration
book

Linux System Administration

by Tom Adelstein, Bill Lubanovic
March 2007
Intermediate to advanced content levelIntermediate to advanced
304 pages
11h 12m
English
O'Reilly Media, Inc.
Content preview from Linux System Administration
Scripting Language Shootout
|
227
Shell scripts run slower.
Shell syntax is icky.
Perl initially filled the gap as administrators looked for more productive tools, but
now PHP has migrated out of its web niche, and Python has gained a reputation for
productivity. We’ll write one application in each of these languages; several others,
such as Ruby and Tcl, are also available on Linux.
Our application will search the /etc/passwd file for name, user ID, hat size, or what-
ever else we can find in there. You’ll see how to open a file, read records, parse for-
mats, search for patterns, and print results. Then we’ll look at ways to avoid some of
this work, because sweat
!= productivity. You’ll be able to apply these techniques to
other files, such as logs or web pages. This is an example of data munging, and you’re
probably doing a lot of it already.
Let’s invent some requirements for our application and express them with this
pseudocode:
read a search string from the user
open the places file
for each line:
parse the fields (columns)
search the name field for a match
if there's a match:
print the other fields in a readable format
By now, many programmers would have rushed in and started typing (some without
having read the data format or requirements). Readers of this book are more disci-
plined, though, as well as better looking. They’ve had to fix the messes that the other
programmers have made and ...
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

Mastering Linux System Administration

Mastering Linux System Administration

Christine Bresnahan, Richard Blum
Mastering Linux Administration

Mastering Linux Administration

Alexandru Calcatinge, Julian Balog

Publisher Resources

ISBN: 9780596009526Supplemental ContentCatalog PageErrata