White Hat Institute

Linux basics

Command-line interface (part 4)

Reading files from the terminal

If you are new to the Linux operating system and you are limited to a terminal, you may think about how to view a document in the command-line. Perusing a document in the Linux terminal isn’t equivalent to opening the file in Notepad. Since you are in the command-line mode, you should utilize commands to read data in Linux.

It’s not that complicated to display a document in Linux. It’s effortless as well as essential that you learn how to read files in the CLI. Here are a few commands that let you view the content of a file in the Linux terminal.

  • – concatenate files: This is the simplest and perhaps the most popular command to view a file in Linux. It merely prints the content of the data to standard output and displays it on your screen.

Linux basics 26
  • -reverse-concatenate files: This is the same as the  command but displays the standard output from bottom to top.

Linux basics 27
  • -number line: The  command is practically similar to the  command. The main contrast is that it prepends line numbers while showing the content in the terminal.

Linux basics 28
  • Pipelines | and : A shell feature called pipelines uses the capacity of commands to peruse information from  and redirect it to Utilizing the pipe option | the standard output of one command can be piped into the standard input of another. To fully demonstrate and understand this, we are going to use it with another command called 

This option views the file one page at a time. The best thing is that when you exit the  command (by pressing ), there are no lines displayed on the screen. Your terminal remains clean and pristine.

Linux basics 29
Linux basics 30
  • : Sort is a Linux program utilized for printing lines of information content records and concatenation of all documents in the arranged request. This command accepts  as field separator and the whole input document as the sort key. It is essential to notice that the  command doesn’t sort the records; however, it only prints the sorted output until you redirect the output.

Linux basics 31
Linux basics 32
  • : This command is utilized to report or exclude rehashed lines; it filters lines from  and composes the result to  After running  on an info stream, you can expel rehashed lines with the  command option.

  • : This command is another way of viewing text files but with a small difference. The  command displays the first ten lines of a text file by default.

Linux basics 33
  • : Tail command in Linux is comparative but inverse to the head command. While the head command shows the document from the earliest starting point, the tail command showcases the record from the end.

Linux basics 34
  • : This operator is a useful document examination filter made primarily for certificate viewing. It shows record content in a page like an arrangement, where clients can press  to see more data.

Linux basics 35
Linux basics 36
  • : With the  command, you can show readable ASCII strings found in binary documents.

  • -word count: The word count command is utilized to show the number of lines, words, and bytes contained in documents.

Linux basics 37
  •  is a powerful file pattern searcher that comes equipped on every distribution of Linux. These filter output lines matching a given pattern. It reads lines from a file or  and prints all matching lines by default to 

Linux basics 38
  • -formatter:  operator is a simple ideal content formatter, it reformats passages in determined documents and prints results to the 

Linux basics 39