50Part ILinux First StepsBackground CommandsSome commands can take (Ipower web hosting)
50Part ILinux First StepsBackground CommandsSome commands can take a while to complete. Sometimes you may not want to tieup your shell waiting for a command to finish. In those cases, you can have thecommands run in the background by using the ampersand (&). Text formatting commands (such as nroffand troff, described earlier) are exam- ples of commands that are often run in the background to format a large document. You also might want to create your own shell scripts that run in the background tocheck continuously for certain events to occur, such as the hard disk filling up orparticular users logging in. Here is an example of a command being run in the background: $ troff -me verylargedocument | lpr & Other ways to manage background and foreground processes are described in the Managing Background and Foreground Processes section later in this chapter. Expanding CommandsWith command substitution, you can have the output of a command interpreted bythe shell instead of by the command itself. In this way, you can have the standard out- put of a command become an argument for another command. The two forms of com- mand substitution are $(command)and `command`(backslashes, not single quotes). The command in this case can include options, metacharacters, and arguments. Here is an example of using command substitution: $ vi $(find /home | grep xyzzy) In this example, the command substitution is done before the vicommand is run. First, the findcommand starts at the /homedirectory and prints out all files anddirectories below that point in the file system. The output is piped to the grepcom- mand, which filters out all files except for those that include the string xyzzy. Finally, the vicommand opens all filenames for editing (one at a time) that include xyzzy. This particular example is useful if you want to edit a file for which you know thename but not the location. As long as the string is uncommon, you can find andopen every instance of a filename existing beneath a point you choose in the filesystem. (In other words, don t use grep afrom the root file system or you ll matchand try to edit several thousand files.) Expanding Arithmetic ExpressionsThere may be times when you want to pass arithmetic results to a command. Thereare two forms you can use to expand an arithmetic expression and pass it to theshell: $[expression]or $(expression). Here is an example:
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services