• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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