Combining Commands

You can combine commands using the Terminal Activity. There are many situations where this is very useful. For example, if you were to use 'ls' the output to the terminal would be a list of all the files and folders in the directory you are currently in. If this is a very long list then the names of the files and folders will flash past so quick you cannot read them. So we can combine the 'ls' command with another command so that we see the list of names one 'page' at a time. To do this we combine the 'ls' command with the 'more' command like this :

ls | more

Now the list of file and folder names will fill up the display area in the terminal but stop when the terminal window is full. It will then wait for you to press the 'space bar' to display the next 'page'.

Combining commands is done using the vertical line that you see in the example command. This must always go between the commands you wish to combine. This line is known as the 'pipe' and in the above example we would say that we "pipe ls through more". That is to say, the output of the 'ls' command is feed through the 'more' command.

You can actually string many commands together in this way. However its good to remember that this does not always work!