You can use wc -l or –lines option to print only the newline counts. By default, wc command prints newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## create a file with 100 lines > myfile; i=1; while [ $i -le 100 ]; \ do echo "$i" >> myfile; ((i++)); done ## default ## newline words byte filename wc myfile ## returns 100 100 292 myfile ## wc -l or --lines option ## newline filename wc -l myfile ## 100 myfile rm myfile |