20,190,829 Wang hair face questions 1, there is a log file access.log, which reads as follows

1, there is a log file access.log, which reads as follows

09:28:59 404 2003356554
09:29:00 200 2003232321
09:30:00 300 2003232321
09:36:00 500 2003232321
09:39:00 200 2003232321
09:40:00 400 2003232321
09:47:00 200 2003232321
...

Now need to count the number of lines that contain 200 characters of the second column, please write commands? (Awk can get only)

Best answer:

[root@localhost ~]# awk '{sum[$2]++} END {print sum["200"]}' access.log
3

Other answers

[root@localhost ~]# awk '{sum[$2]+=1} END {for(a in sum) print  a,sum[a]}' access.log 
 1
300 1
400 1
200 3
404 1
500 1
[root@localhost ~]# awk '{sum[$2]+=1} END {for(a in sum) print  sum[a]}' access.log 
[root@localhost ~]# awk '{sum[$2]+=1} END {print sum["200"]}' access.log
3
[root@localhost ~]# awk '{++sum[$2]} END {print sum["200"]}' access.log 
3
[root@localhost ~]# awk '{sum[$2]+=1}END{for(i in sum)print i"\t"sum[i]}' access.log  | grep 200
200 3
[root@localhost ~]# awk '{print $2}' access.log | sort -n | grep 200 | wc -l
3
[root@localhost ~]# awk  '{print $2}' access.log | grep -w "200" | wc -l
3
[root@localhost ~]# awk '{if($2=="200")sum++}END{print sum}' access.log
3

2, please write the default port number for the following services

SSH:22 Telnet:23 SMTP:25 POP3:110 DNS:53 FTP:20,21

HTTPS: 443 HTTP: 80 Remote Desktop: 3389

3, linux command topic

a. Create admin directory / home directory

b. Set the group that owns the directory is admin

c. Requirements members of the group have read and write access to the directory, and group members also belong to the admin group to create a file

[root@localhost ~]# mkdir /home/admin

[root@localhost ~]# chown .admin /home/admin
[root@localhost ~]# ls -ld /home/admin
drwxr-xr-x. 2 root admin 6 Aug 30 00:13 /home/admin

[root@localhost ~]# chmod g=rwxs /home/admin

4, linux below rhel6.4.iso mirror mount to / mnt

If rhel6.4.iso just inside of a hard disk file

[root@localhost ~]# mount rhel6.4.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only
#如果报错,手动执行loop
[root@localhost ~]# mount -o loop rhel6.4.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only

If it is a CD-ROM drive:

[root@localhost ~]# mount /dev/cdrom /mnt

7, using the route add default gateway 172.41.8.100

route add default gw 172.18.8.100

8, processes and nginx nginx command to view the listening port

ps -ef | grep nginx
ss -ltn | grep nginx

9, linux view the system resources

top
free
vmstat
iostat

Guess you like

Origin blog.51cto.com/14012942/2433698