Basic Syntax
Common Use Cases
1. View a File’s Content
Displays the contents of filename.txt
on the terminal.
2. View Multiple Files
Shows the contents of both files, one after the other.
3. Create a New File
Start typing, then press Ctrl + D
to save and exit.
4. Append Text to a File
Adds content to the end of the file. Press Ctrl + D
to stop.
5. Concatenate Files and Save Output
Combines the two files into a new file called combined.txt
.
6. Show Line Numbers
Displays the file with line numbers.
Some Useful Options
Option | Description |
---|---|
-n | Number all output lines |
-b | Number non-blank lines only |
-s | Squeeze multiple blank lines into one |
-T | Show TAB characters as ^I |
-E | Show $ at the end of each line |
Example
Output: