linux count which lines appear a string no grep code example Example 1: grep count lines wc -l myfile Example 2: grep count lines cat -n myfile