Which command is used to view the contents of a file in Linux?

0227

In Linux, the cat command is commonly used to view the contents of a file. The basic syntax is:

cat filename

Replace filename with the name of the file you want to view. For example:

cat example.txt

Additionally, you can use other commands like less, more, head, and tail to view file contents in different ways:

  • less filename: View the file contents one screen at a time, allowing for scrolling.
  • more filename: Similar to less, but with more limited navigation.
  • head filename: View the first few lines of the file (default is 10 lines).
  • tail filename: View the last few lines of the file (default is 10 lines).

These commands provide various options for inspecting file contents in Linux.

0 Comments

no data
Be the first to share your comment!