# Chapter 28. Saving Time on the Command Line

#### Contents:

What's Special About the Unix Command Line
Reprinting Your Command Line with CTRL-r
Use Wildcards to Create Files?
Build Strings with { }
String Editing (Colon) Operators
Automatic Completion
Don't Match Useless Files in Filename Completion
Repeating Commands
Repeating and Varying Commands
Repeating a Command with Copy-and-Paste
Repeating a Time-Varying Command
Multiline Commands, Secondary Prompts
Here Document Example #1: Unformatted Form Letters
Command Substitution
Handling Lots of Text with Temporary Files
Separating Commands with Semicolons
Dealing with Too Many Arguments
Expect

## 28.1. What's Special About the Unix Command Line

> #### Summary Box One of Unix's best features is the shell's command line. Why? Nearly every modern operating system has a command line; we don't use card readers with obscure job setup cards any more. What makes Unix's special? The Unix shell command line allows lots of shortcuts. Some of these you'll find in other operating systems; some you won't. In this chapter, we'll introduce a lot of these shortcuts. Among other things, we'll discuss: How to run commands more than once (Section 28.8). Filename completion (Section 28.6, Section 28.7), which allows you to type the beginning of a filename and let the shell fill in the rest. (This is finally possible on certain Redmond-born OSes as well, but it usually involves a registry hack or two.) Command substitution (Section 28.14), which lets you use the output from one command as arguments to another. (Note that this is different from pipelining.) Process substitution in bash, and a script named ! for other shells, lets you put the output of a command into a temporary file and give that filename to a process. The ability to repeat commands with various methods (Section 28.10, Section 28.11). Handling of command lines that become too long (Section 28.17). Some fundamental command-line features that we aren't discussing in this chapter, but which are discussed elsewhere, are: Job control (Section 23.3), which lets you run several commands at the same time. Aliases (Section 29.2), or abbreviations, for commands. Shell functions (Section 29.11) are similar. Command-line editing (Section 30.14) and history substitution (Section 30.8). These are two different ways (both useful) to "recall" previous commands. Quoting (Section 27.12, Section 27.13), the way you "protect" special characters from the Unix shell. Wildcards (Section 33.2). You don't need to be a command-line virtuoso to use Unix effectively. But you'd be surprised at how much you can do with a few tricks. If all you can do at the command line is type `ls` or start Mozilla or the Gimp, you're missing out on a lot. -- ML

Copyright © 2003 O'Reilly & Associates. All rights reserved.