This article refers to the example on the http://www.docin.com/p-56167731.html
1. Statistics of the number of rows of a file can be made with the following command:
Grep-c "" Xxx.txt
Or
Grep-n "" Xxx.txt | Wc-l
___________________________
Ps:
Use the Grep-n "" Xxx.txt to display line numbers for xxx.txt content.
Like what
Grep-n ""/etc/passwd
Output results:
1:root:x:0:0:root:/root:/bin/bash
2:daemon:x:1:1:daemon:/usr/sbin:/bin/sh
3:bin:x:2:2:bin:/bin:/bin/sh
4:sys:x:3:3:sys:/dev:/bin/sh
5:sync:x:4:65534:sync:/bin:/bin/sync
6:games:x:5:60:games:/usr/games:/bin/sh
7:man:x:6:12:man:/var/cache/man:/bin/sh
8:lp:x:7:7:lp:/var/spool/lpd:/bin/sh
9:mail:x:8:8:mail:/var/mail:/bin/sh
10:news:x:9:9:news:/var/spool/news:/bin/sh
....
____________________________
Or
Cat Xxx.txt | Wc-l
____________________________
Ps:
You can also output text content with line numbers by using the Cat-n Xxx.txt method
And it's better than the grep-n effect.
Like Cat-n/etc/passwd.
1 Root:x:0:0:root:/root:/bin/bash
2 daemon:x:1:1:daemon:/usr/sbin:/bin/sh
3 bin:x:2:2:bin:/bin:/bin/sh
4 sys:x:3:3:sys:/dev:/bin/sh
5 Sync:x:4:65534:sync:/bin:/bin/sync
6 games:x:5:60:games:/usr/games:/bin/sh
7 man:x:6:12:man:/var/cache/man:/bin/sh
8 lp:x:7:7:lp:/var/spool/lpd:/bin/sh
9 mail:x:8:8:mail:/var/mail:/bin/sh
Ten news:x:9:9:news:/var/spool/news:/bin/sh
...
In addition, a simpler command with a line-number output file is NL, which is equivalent to Cat-n
____________________________
2. Statistics command execution results of the number of rows
find/etc/-type F | Number of files under Wc-l #统计/etc/
find/etc/-type f-name "*iscsi*" | Wc-l #统计文件名中带有iscsi的文件数
find/etc/-type f-exec grep "Mdadm" {}/; | Wc-l #统计/etc/Directory, number of rows with mdadm content
find/etc/-type f-name "*iscsi*" | awk ' End{print NR} ' #统计文件名中带有iscsi的文件数
find/etc/-type f-exec grep "Mdadm" {}/; | awk ' End{print NR} ' #统计/etc directory, number of rows with mdadm content