UNIX IX: Advanced Shell Commands
- Pipes allow you to connect the output of one program to
the input of another, and are denoted by the "|" character. For
example, ls | more sends the output of ls through
the more program. This is useful if you have lots of files
in a directory.
- What does ls | lpr do?
- Wildcards allow you to run a command on all the files
in a directory matching certain criteria. The wildcard "*" matches
any sequence of letters and the wildcard "?" matches any single
character. For example, rm *.c removes all the files in the
current directory ending in ".c".
- What does mv *.bak /tmp do?
- UNIX is a multitasking operating system and allows you to have
several programs running at once. These programs are divided into
foreground tasks which have the ability to do input/output
from a terminal (or xterm) and background tasks which don't.
- To run a program foobar in the background, just type
foobar &.
- To move the current foreground task in the background, type
Control-Z.
- To see which programs are running, type jobs.
- To move a background task in the foreground, type
fg %(job number) .
- Finally, shells allow you to redirect where the input and output
come from and go to. Typing command > filename
tells command to put its output into filename. Similarly,
typing command < filename tells command
to take its input from filename.
Next Slide