There are many commands that you can make use of on the bash shell to display the contents of a file in the Terminal. Let's take a look at some of the most common ones.
Example: Using cat command
We can make use of cat command to display the contents of a file in Terminal.
bash-3.2$ cat data.txt Date,Temp 1-1-2023,22 2-1-2023,22.3 3-1-2023,22.2 4-1-2023,22.1 5-1-2023,22.3
You can also access the file using absolute path to display it's content.
cat /Users/c2ctech/Desktop/data.txt Date,Temp 1-1-2023,22 2-1-2023,22.3
Example: Using less command
If you have a file that is huge, then you can make use of the less command, this will display the contents of the file page wise with navigation option.
$ less huge_data.txt
Example: Using more command
Again when have a file that is huge, then you can make use of the more command, this will display the contents of the file page wise and you can scroll to view the contents.
$ more huge_data.txt
Example: Using head command
The head command can be used if you just want to display the n-number of lines from top of the file.
$ head -n 10 huge_data.txt
Example: Using tail command
The tail command can be used if you just want to display the n-number of lines from bottom of the file.
$ tail -n 10 huge_data.txt
Facing issues? Have Questions? Post them here! I am happy to answer!
- Bash Hello World! Script Tutorial
- How to run bash command in background
- How to create new user account in Windows bash
- How to Compare Strings in Bash
- Bash: Allow Command to Fail without exiting Script
- Fix bash: script.sh: Permission denied Error
- Bash getopts Command Example
- How to fix bash ping command not found error
- How to add NewLine Character in Bash Script String
- How to Echo Bash Command to a File
- Bash Command to Find String in a File
- How to open new Terminal using Bash Command
- Bash How to Save Output of a Command to a Variable
- Download a SSL Certificate from a URL in Terminal
- Bash Command to Check IP Address
- Know Bash shell version command
- Bash Command To Check If File Exists
- How to run a Command in Bash Script
- How to Compare two Files in Bash Shell
- How to check if a variable is set in Bash Script or Not
- Convert String from uppercase to lowercase in Bash
- How to see Created Accessed Modified and Changed dates of a file using bash terminal command
- Bash Command To Get Current Time
- Bash command to List Files
- Fix: bash: syntax error near unexpected token
- Keyboard shortcut to close tab in Notepad++ - NotepadPlusPlus
- SwissCovid App Launched in Switzerland - News
- Notepad++ Hex Editor - NotepadPlusPlus
- Android Eclipse This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in - Android
- How to restore closed file in Notepad++ - NotepadPlusPlus
- Relative Imports examples in Python 3.x - Python
- How to set CSS background-Image Property - CSS
- Terminal display next month Calendar - Linux