Dave's Brain

Browse - Computer Tips - How can I get grep to show line numbers of its hits?

Date: 2016apr16
OS: Linux
Product: grep
Level: beginner

Q.  How can I get grep to show line numbers of its hits?

A.  Use the -n option like this:

grep -n <pattern> <file>

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.