grep show line numbers code example Example 1: grep count lines cat -n myfile Example 2: grep count lines grep -c ^ filename