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 ?
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 ?
For short files:
directly shows a text file in the terminal.
For longer files:
lets you scroll and search (/
text to search
Enter) in the file; press q to exit.e.g.
Another alternative is
vim
.Once you opened a file with vim you can insert text by typing
i
, for instance. If you want to save your file use:w
(write) or:q
(quit) or:wq
(for write and quit) or:q!
(quit and do not save). Sometimes you need to hit the ESC key to be able to type the commands.Vim requires some learning, but is widely used and it is very versatile.
Check the community help wiki: https://help.ubuntu.com/community/VimHowto
all those are best ways and there is one more way to do this & that’s with
head
command.and
both will give you the same input.
Head command Explanation:
Generally head command used to print the starting lines of the any text file.we can view the text file with
That will prints the 1st 10 lines of the above text file.
If you want to specific on the number of lines which are to be view then you can use head as
Then in the above text file first 20 lines will be viewed.
If you want to view whole file data with head means then then we can get it by
Hope that above explanation will give you some idea on usage of head.
If the file is rather long, you might want to use
so that you can navigate through it with directional keys.
Another option is:
to print out the last 30 lines of a large file named
result.txt
.Another option:
It will show you the last ten lines of
your_file
. If a process appends something to this file, you see it on your terminal.man tail
gives you more ontail
.It's useful to see what happens with a server when you use this command on a log file.
Press Ctrl-C to quit when you are done viewing.
There are a lot of alternatives for doing that:
Some of these programs have a lot of parameters, so check that out with --help after the command..
cat filename
prints the whole file at oncemore
/less filename
similar behaviour for see the file in partstail filename
start reading from the tail of the filegrep text filename
for filtering resultsHope that some of this works for you..
With a terminal text editor:
nano /path/to/file/RESULTS.txt
As we seem to be listing all available alternatives of displaying any text file in the terminal, it would be quite fun to introduce
pv
as technically one valid (but unusual) method, although I would normally usecat
instead for most things.It is in the repositories and so can be installed with
sudo apt-get install pv
if you don't have it already.As the man page notes,
pv
is very often used toWith
pv
you can literally print the file to the screen, and choose the rate (-L
) at which it appears. The example below uses a high rate (300), but if you choose a low rate such as-L 50
, it will appear as if the computer is typing out the file for you.Needless to say you can increase the rate further (
-L 8000
), and the command becomes very similar tocat
, with the output appearing instantaneously.For more information see
man pv
or the Ubuntu manpages online.If you just want to read the file content, go in the file directory and type
If you want to read and edit the text file, from the same directory type
The
-w
switch in the nano command can be inserted before the file name to prevent wrapping of long lines.