In order to display the contents of a file in macOS/Linux/Unix Terminal you can make use of cat command - read more
Sample File:Lorem ipsum dolor sit amet
ut mea nostrum detracto quaestio.
Eu nobis denique fabellas est,
clita liberavisse duo an.
Nam vidit falli disputationi eu
usu nonumy nostro eirmod no.
Liber dictas incorrupte eum ex.
Qui illum singulis ei,
duo te democritum disputationi,
facer iisque aliquid ad eos.
In order to display the line numbers along with the text on the console we can make use of option -n along with the cat command and file name,
Example:$ cat -n myfile.txt
1 Lorem ipsum dolor sit amet
2 ut mea nostrum detracto quaestio.
3 Eu nobis denique fabellas est,
4 clita liberavisse duo an.
5 Nam vidit falli disputationi eu
6 usu nonumy nostro eirmod no.
7 Liber dictas incorrupte eum ex.
8 Qui illum singulis ei,
9 duo te democritum disputationi,
10 facer iisque aliquid ad eos.
![Display line number in terminal for text file Display line number in terminal for text file](https://code2care.org/linux/display-line-numbers-in-terminal-while-displaying-content-of-a-file/images/Display line number in terminal for text file.png)
Display line number in terminal for text file
More Posts related to HowTos,
- [Fix] Error 1020 Cloudflare: Access was denied
- What is an Authorization Code Grant? OAuth 2.0
- Fix: psql: error: connection to server at localhost (::1) port 5432 failed: FATAL: database does not exist
- 100+ SEO Tips to improve your website search ranking
- How to submit website to dmoz directory
- How to check the version of NodeJS installed
- How to enter Rockstar Activation Code?
- Background task activation is spurious error - Windows 10, Office 2016, Office 365
- Angular CLI ng Error: You need to specify a command before moving on. Use --help to view the available commands
- cURL HTTP GET request command examples
- Fix - JioCinema Something Went Wrong Please Try Again Error 8001 while streaming IPL Cricket Live
- How to remove password from pdf file
- How to identify the version of IntelliJ
- Command: How to scp a file to remote server location?
- How to add Widgets to MacBook Desktop
- Setting up RSS feeds notifications within Outlook
- Fix - Website Connection timed out Error Code 522 (Cloudflare)
- How to fix: Please check your network connection (Retry)
- Fix: Could not connect to Redis at 127.0.0.1:6379: Connection refused
- Accept Only 0-9 Numbers RegEx Example
- How to create a New Project in Visual Studio Code (VS Code)
- Top 10 emerging breakthrough trending technologies
- Free Unlimited Calls from MTNL & BSNL Landlines from 1st May 2015
- [Error] zsh: command not found: mvn
- How to Scan iPhone for Virus? Is Antivirus it really required?
More Posts:
- Implementing Bubble Sort Algorithm using Java Program - Java
- [Notepad++] Could Not Load Session - Session file is either corrupted or not valid - NotepadPlusPlus
- Fix: Windows Update Error Code: 0x800f0922 - Windows
- 🎃 Halloween Hashtag 2022 on Social Media 🎃 - Hashtags
- Fahrenheit to Celsius Temperature Convertor: Tool & Formula - Tools
- How to close tabs on Notepad++ on Click? - NotepadPlusPlus
- How to open TextEdit from Mac Terminal - MacOS
- bash: ls command to see list files in current directory all subdirectories - Bash