When you use cat -n on a completely empty file, it produces no output at all.
Here is how it behaves in different "empty" scenarios:
1. A Truly Empty File (0 bytes)
If the file contains absolutely no data, cat -n will simply return you to the command prompt without printing anything. Since there is no content, there are no lines to number.
2. A File with Only Empty Lines
If a file has content but some lines are blank (e.g., you pressed "Enter" a few times), cat -n will assign numbers to those blank lines.
Example:
If /tmp/blank_test contains:
Line 1: Hello
Line 2: (Empty)
Line 3: World
The command cat -n /tmp/blank_test will show:
1 Hello
2
3 World
Pro Tip: cat -b
If you only want to number lines that actually have text and skip numbering blank lines, you can use the -b option instead:
cat -b /tmp/blank_test
This would number "Hello" as 1 and "World" as 2, leaving the blank line unnumbered.