Tips and Tricks
Before we move on to the next case study, we will cover some material that is helpful, but was not covered in previous chapters. They fall into various categories and make some operations much easier. We will briefly describe some of them. Some of the information here will also be needed to solve the problems in Activity 10 in this chapter.
Suppressing Command Output
UNIX-like OSes provide a special file, called /dev/null
, that can be used as a "black hole" for any data. Any writes to that file silently succeed and the data is discarded. This is useful when you need to suppress the output of commands. For instance, look at the following command:
ls >/dev/null
This runs ls
and silently discards its output. Redirecting to /dev/null
is usually helpful when suppressing error messages from commands that are run in a script.
Arithmetic Expansion
So far, we have used the $(( EXPR ))
syntax for arithmetic expressions. However, there are some variations...