Ubuntu – How to open a text file in the terminal

command linefilestext-editor

There is a file named RESULTS.txt and I want to open this file in my terminal. (I mean I want to see the file contents be displayed in the terminal and not in some text editor)

How do I do that ?

Best Answer

For short files:

cat <path/your_file>

directly shows a text file in the terminal.

For longer files:

less <path/your_file>

lets you scroll and search (/ text to search Enter) in the file; press q to exit.

e.g.

cat /home/john/RESULTS.txt
less /home/john/RESULTS.txt