-->
Previous | Table of Contents | Next |
To view the contents of a file, you can again use the more command. Just specify the name of the file you want to look at. In this case, type more output.
Warning:
Be careful! When you use >, you completely overwrite the previous contents of the file from which you specify to take the output (if that file existed). For example, if we already have a file called output in our directory, its old contents will be completely replaced by the output from ls -l /bin. Linux will not warn you that you are about to do this!Be particularly careful if youre not in your usual directory or if youre logged in as root. You could, for instance, accidentally clobber a Linux program by mistake. Its a good idea to check whether the output file already exists before using >. In our example, we could have typed ls -l output beforehand. If no information is displayed, the file does not exist.
You can specify that you want to add your output to the end of the file, rather than replace the files contents, by using >>. Type who >> output to add the output of the who command to the end of the text already in the file output.
You can examine the results by using either more or less and paging through to the end of the file or by using the Linux command tail, which displays the last few lines of the specified file. In this case, type tail output to see the last few lines of the file output. Try using tail!
There is a set of accepted notational conventions used to describe, in a concise and consistent way, the correct syntax for any given Linux command. This specifies what options or parameters you must use, what options or parameters you can or cannot use, and so on. Sometimes this set of conventions is used to give a complete and exhaustive listing of a commands syntax, showing every possible command and parameter. Sometimes it is used to make a particular example more general and the commands basic usage clearer. Youll run into these notations in manuals, man pages, and other sources of information.
If you remember the following five basic rules, you will be able, in principle, to understand the syntax of any Linux or UNIX command.
Previous | Table of Contents | Next |