Introduction

Introduction

Gathered here is a collection of what we consider to be some of the more useful Linux tools. What qualifies them to be included in this chapter? For starters, the majority are command line tools. Being command line junkies and programmers, we feel some of the best tools are those that can be typed, piped, and batched. Additionally, these tools are used almost daily by all of the authors for a host of daily functions. Some qualify because they have been staples of the Unix operating system since the 1970s. Accompanying each tool listed in this chapter is a short explanation of its function and how it is used most often.

The tools are loosely organized into categories. Obviously some tools cross multiple categories, so the grouping is mostly arbitrary. Besides, it's just easier to read something in outline form. No ranking was considered when making this list.

Why is this chapter in the middle of the book? We've already introduced a lot of tools and many uses for those tools. This seemed to be a good place to pause and reflect on some specific tools that we felt needed special attention. Consider this a break from the normal style each chapter uses to introduce the various tools available.

Regular Expressions

The first tool you should start learning is regular expressions, or REs. A regular expression is a string of characters that matches patterns and/or does substitutions. Regular expressions are used in a great many Linux and Unix tools, from grep to sed to Perl (where they reach perhaps their greatest functional height). Mastery of regular expressions is the mark of the Unix fluent, and once you start using them intuitively, you will wonder how you ever lived without them.

Pipes and Redirection

Pipes and redirects are basic Linux and Unix skills. Most command line programs in Linux take input from standard input, usually the keyboard, and write to standard output, usually the display terminal. Redirection allows you to change where standard input comes from or where standard output goes to, for example:

echo -e "larry\ncarry\nbarry\nmary" > myfriends.txt

In this example, I created a list of my friends using the echo command and then put them into a file by redirecting the standard out of the echo command to the file myfriends.txt. But what if I wanted a sorted list? Read on.

A pipe performs a similar thing to redirection, but in many ways it is more useful. A pipe allows you to connect the standard output of one program to the standard input of another. Expanding on my friends examples, let's make that friends list, sort it, and finally put it into a file:

echo -e "larry\ncarry\nbarry\nmary" | sort > myfriends.txt

The list is now being piped from the echo command into the sort command, where the list is sorted. The default behavior of the sort command is to print out the results to standard out. I redirected the output of sort to the file myfriends.txt. The file now contains the sorted list of my friends. Not only do I have a pathetically small number of friends, but apparently I also have a bizzare attraction to people with similar names .

 



Multitool Linux. Practical Uses for Open Source Software
Multitool Linux: Practical Uses for Open Source Software
ISBN: 0201734206
EAN: 2147483647
Year: 2002
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net