bash - How to print out the number of lines in an output command -
for example:
cat /etc/passwd what easiest way count , display number of lines command outputs?
wc unix utility counts characters, words, lines etc. try man wc learn more it. -l option makes print number of lines (and not characters , other stuff).
so, wc -l <filename> print number of lines in file <filename>.
you asked how count number of lines output command line program in general. that, can use pipes in unix. so, can pipe output of command wc -l. in example, cat /etc/password command line program want count. should do:
cat /etc/password | wc -l
Comments
Post a Comment