How to count the lines of an output in the terminal?

Asked

Viewed 67 times

3

I want to count the total outputs of the results in the terminal.

For example using the cat lista_de_compras.txt:

arroz
feijão
leite

I want to receive 3

1 answer

7


Use the grep:

grep -c ^ lista_de_compras.txt

The exit will be 3


or user the cat with the wc

cat lista_de_compras.txt |wc -l

The exit will be 3


Or just use the wc:

wc -l lista_de_compras.txt

The exit will be 3


Browser other questions tagged

You are not signed in. Login or sign up in order to post.