O'Reilly logo

Unix for Oracle DBAs Pocket Reference by Donald K. Burleson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Unix Commands

One of the most confounding things for the Unix neophyte is being confronted with a complex Unix command. The cryptic nature of Unix is such that even the most seasoned Unix professional may have trouble deciphering such a command. Hidden in that complexity, however, is a great deal of power. In order to leverage that power for your day-to-day work, it's essential for you to learn how to deal with complex commands.

In this section, we will begin by examining a cryptic Unix command in order to see how it is really composed of many simpler commands. We'll then walk through the process of creating such a command in order to perform a specific task.

Regarding the terms commands and scripts, you should note that any command may become a script if it is encapsulated into a file for execution. Hence, find . -print can be a command if executed from the prompt, or a script if placed into a file.

Decompose a Complex Unix Command

This section shows how a Unix programmer can string commands together into a powerful one-line command. The following one-line Unix script performs an important Oracle function—it kills all Oracle background processes when the database cannot be shut down normally:

ps -ef|grep "ora_"|grep -v grep|awk '{ print $2 }'|xargs kill -9

At first glance, this Unix command appears to be a conglomeration of cryptic letters. However, this is actually a series of commands that are joined together using the pipe operator (|). Here's a view of the command that's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required