How to display the contents of a text file in Bash?

To display the contents of a text file in Bash, you can use the cat command. Here's how you can do it:

  1. Open your Terminal or Command Prompt.
  2. Navigate to the directory where the text file is located using the cd command. For example, if the file is located in the "Documents" folder, you would enter: cd Documents
  3. Once you are in the correct directory, type the following command to display the content of the text file: cat filename.txt Replace filename.txt with the name of your text file.
  4. Press Enter, and the contents of the text file will be displayed in the terminal.

If you want to display the content of multiple text files, you can provide multiple filenames separated by spaces. For example: cat file1.txt file2.txt file3.txt

Additionally, if you want to scroll through long files, you can use the less command instead of cat. This way, you can scroll through the content using the arrow keys. Simply replace cat with less in the command: less filename.txt.