Don’t use cat or any other tool which is not designed to do that. Use the program:
nl – number lines of files
Example:
$ nl --number-format=rz --number-width=9 foobar
$ nl -n rz -w 9 foobar # short-hand
Because nl is made for it 😉
More Related Contents:
- What does 2>&1 mean here?
- How to reload .bashrc settings without logging out and back in again?
- How do I iterate over a range of numbers defined by variables in Bash?
- When do we need curly braces around shell variables?
- How to loop through file names returned by find?
- How to manually expand a special variable (ex: ~ tilde) in bash
- Accessing bash command line args $@ vs $*
- Bash command line and input limit
- How can I escape a double quote inside double quotes?
- When are square brackets required in a Bash if statement?
- Bash syntax error: unexpected end of file
- How to assign the output of a Bash command to a variable? [duplicate]
- What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
- Is there a TRY CATCH command in Bash
- Parsing variables from config file in Bash
- Bash variables with spaces
- Is it possible for bash commands to continue before the result of the previous command?
- How to remove (base) from terminal prompt after updating conda
- Retrieving multiple arguments for a single option using getopts in Bash
- grep for expression containing variable
- Stop on first error [duplicate]
- Is mixing getopts with positional parameters possible?
- Saving current directory to bash history
- How to check if running as root in a bash script
- Print a file’s last modified date in Bash
- How to iterate over list which contains whitespaces in bash
- Multi Level Bash Completion
- In Bash test if associative array is declared
- Left side of pipe is the subshell?
- How to read variables from file, with multiple variables per line?