How do you display file contents line by line in Linux?
Below are the commands that can be used in Linux to display the contents of a file line by line.
cat -n 文件名
This command will display each line of a file, with a line number added at the beginning of each line. For example, to display the contents of the file test.txt line by line, you can use the following command:
cat -n test.txt
If you do not want to display line numbers, you can use the following command:
cat 文件名
For example:
cat test.txt
Another option is to use the “more” command to display the contents of a file line by line. For example:
more 文件名
This command will display a portion of the file at a time, you can press the spacebar to display the next portion of content, and press the q key to exit.