LINUX TIPS AND TRICKS --- March 24, 2000

Published by ITworld.com, the IT problem-solving network
http://www.itworld.com/newsletters

*********************************************************************

Wildcards and Command History
by Danny Kalev

My previous column discussed filename auto-completion. In this column, I
will show two more useful techniques that can save you a lot of
keystrokes -- namely filename wildcards and command history.

- Wildcards -
The bash command shell accepts two characters as filename wildcards -- 
an asterisk and a question mark. You can use these wildcards when you 
need to perform operations on a group of files, e.g., copying, 
compressing or deleting a directory. The ? character matches any single 
character in a filename. Suppose the current directory contains the 
following files:

  inventory.tmp
  inventory.bmp
  inventory.dat

You wish to delete inventory.tmp and inventory.bmp at once, while
retaining inventory.dat. Type the following command:

  $ rm inventory.?mp

Consequently, the shell command will delete the files inventory.tmp and
inventory.bmp. If you wish to delete any file called "inventory" that
has a three letter extension, use the following command:

  $ rm inventory.???

The wildcard * is less restrictive than ?. It matches any number of
characters (including zero). For instance, if the current directory
contains the following files:

  vir.exe
  virus.exe
  dialer.exe
  shapes.plx
  clip.mov

then, to delete the files vir.exe and virus.exe, type the following 
command:

  $ rm vir*.exe

To remove all the files in the current directory, use the following
command:

  $ rm *.*

- Command History -
The bash command shell remembers the commands you've typed recently. You
can retrieve these commands by pressing the up and down keys. Pressing
the up key retrieves the most recent command you typed; repeat this step
to navigate the contents of earlier commands. Command history retrieval
is useful when you want to repeat the same operation several times. You
may also edit the contents of the previously typed commands using the
right and left keys. For example, to uudecode the following files in a
sequence:

  picture1.uue  
  picture2.uue

First type the following command:

  uudecode picture1.uue

The uudecode utility will decode the file. Next, press the up key. The
previous command will appear again. Move with the right key until the
cursor is located on the number 1, type "2", and the command will change
to:

  uudecode picture2.uue

now press Enter.

Next Week: Creating A Child Process

If this column has raised questions or comments, let's hear them. Join 
my upcoming Linux Software Development discussion, which goes live on 
March 27, 2000, on ITworld.com's Linux Forum: 
http://forums.itworld.com/webx?14@@.ee6b652.

About the author
----------------
Danny Kalev is a system analyst and software engineer with more
than 10 years of experience, specializing in C++ and
object-oriented analysis and design on various platforms including
VMS, DOS, Windows, Unix, and Linux. His technical interests involve
code optimization, networking, and distributed computing. He is
also a member of the ANSI C++ standardization committee and the
author of ANSI/ISO C++ Professional Programmer's Handbook (Que,
1999). Contact him at danny.kalev@linuxworld.com.
 
