View Linux History Range 100 to 200 | Generated by AI
Question: In Linux history command, how to show commands from the 100th most recent to the 200th most recent (not just the last 100)?
Answer:
The history command numbers entries from oldest (small number) to newest (large number).
To see commands from the 100th most recent to the 200th most recent, you need to use negative offsets or calculate the absolute line numbers.
Here are the most practical ways:
1. Easiest & recommended way (using negative offsets)
history | tail -n 200 | head -n 100
This shows:
- last 200 commands (most recent 200 lines)
- then takes the first 100 of those → which are exactly commands 200th-oldest to 101st-oldest (i.e. 100th-most-recent to 200th-most-recent)
2. More explicit version (very clear what you’re doing)
# Show from 100th last → 200th last
history | tail -n +101 | head -n 100
tail -n +101→ skip the newest 100 lines, start from the 101st newesthead -n 100→ take the next 100 lines after that
3. Using negative range (bash 4+)
# Show history entries from -200 to -100 (inclusive)
for i in {100..200}; do history -$i; done
or shorter (but less readable):
history | sed -n '101,200p'
Quick summary – most common useful patterns
| What you want | Command |
|---|---|
| Last 100 commands | history 100 or history | tail -100 |
| Commands 100–200 ago (your question) | history | tail -n 200 | head -n 100 |
| Commands 101–200 ago | history | tail -n +101 | head -n 100 |
| Commands 50–150 ago | history | tail -n 150 | head -n 100 |
| Last 300 → skip newest 100 | history | tail -n 300 | head -n 200 |
The most readable and commonly used version for your exact case is:
history | tail -n 200 | head -n 100
References:
- None (standard Linux/POSIX
history,tail,headbehavior)