How to view the contents of a txt file in Linux?

To view the contents of a txt file on Linux, you can use a command line tool. You can use the following command to view the file content:

cat 文件名.txt

This command will display the entire content of the txt file on the terminal.

You can also use the following command to view part of the file’s content:

head 文件名.txt

This command will display the first few lines of a txt file.

tail 文件名.txt

This command will display the last few lines of the txt file.

In addition, you can also use a text editor to view the contents of a txt file, such as using the vim or nano editor. Here are the commands for using the vim editor:

vim 文件名.txt

This command will open a txt file in the vim editor, allowing you to browse the content of the file using arrow keys and Page Up/Page Down keys.

The commands for using the nano editor are as follows:

nano 文件名.txt

This command will open a txt file in the nano editor, allowing you to browse the contents of the file using arrow keys.

Here are some commonly used methods in Linux to view the content of a txt file.

bannerAds