How to Display the Contents of a File in Unix
Viewing a file in UNIX can help you find and fix errors while also allowing you to see the entire contents at once. UNIX has a few simple commands for viewing a file. Follow the instructions below to display the contents of a file in UNIX.
Instructions
-
-
1
Open your UNIX program and wait for the prompt cursor to appear. There are four different commands that you can use to view a file. Choose the command that works best for your situation.
-
2
At the UNIX prompt, type in "cat" followed by the file name you wish to view. If the name of your file is cars, for example, type in "cat cars." Immediately the entire file will scroll on the screen without pausing. This works well for short files that don't scroll off the screen.
-
-
3
At the prompt, type the word "view" followed by the file name to view the file in read-only mode. You cannot edit the file in this mode.
-
4
Type the word "more" followed by the file name to view the file page-by-page. The file will pause on every page and will scroll only when you press the "Enter" key. Use the More command to examine a file more thoroughly.
-
5
Type the word "less" and follow it by the file name for even greater control in viewing the file. Use the less function when you want to scroll both backwards and fowards within a file. The less function also lets you scroll through a file slowly.
-
1
Tips & Warnings
Enter all commands in lower case.