Home / Server side scripting / Linux / Linux Command To View File

Linux Command To View File

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

OR

# cat /home/hello.txt

Sample outputs:

Hello world

nameserver  101.2.3.4

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

Hello world..

If you are using OS-X unix then try ‘open’ command as follows.

open file.pdf

open onelove.mp3

open staywithme.mp4

open http://www.nixlinux.com

Hope the above helped you a bit ๐Ÿ™‚

Jishnu KS

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป
Social Media Auto Publish Powered By : XYZScripts.com