• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Is there an ez way to number lines in a file. skipping the first 2 lines.

I have a file:

Junk
junk
rule
rule
rule

I want to  cat -n the file and start counting at the first rule.  the first two lines would not be "counted"

-1
0
1
2
3
4
5
 
would be more like the numbering I would like to see from cat or something else.  

0
TIMFOX123
Asked:
TIMFOX123
1 Solution
 
amit_gCommented:
LineCount=$(wc -l TheFileName | cut -d" " -f1); tail -n $(($LineCount - 2)) TheFileName | cat -n
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now