count grep lines linux code example Example 1: grep count lines wc -l myfile Example 2: grep count lines cat -n myfile Example 3: grep count lines cat myfile | wc -l