There are a number of options available in Linux and Unix systems to view a text file. There will occur situations in which we just need to view the contents of the files and also to search for a particular word, line, command in it.
The following commands can be can be used to view a text file or any other files such as doc, pdf, video, mp3 and more.
- cat command
- less command
- more command
View a text file named hello.txt in a Linux or Unix-like systems
Open the terminal window and type in the following command to view the text file using cat command.
# cat hello.txt
# cat /home/hello.txt
You can also view the file using the less command as follows.
# less hello.txt
To exit after viewed the file you can just hit the Q button on the keyboard when you use less command.
The more command has a similar usage as that of the cat command. It shows the content in the terminal window directly.
# more hello.txt
If you are using OS-X unix then try ‘open’ command as follows.
Hope the above helped you a bit 🙂
- Load Average on Linux and Unix-like Systems Explained - May 16, 2020
- How to Install Webmin on CentOS/RHEL 7/6/5 – Linux - May 16, 2020
- List addon domains, parked domains and sub domains via command line – cPanel - May 13, 2020