假设命令运行的结果我们存储在nowcoder.txt里,格式如下: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 37344 4604 ? Ss 2020 2:13 sbininit root 231 0.0 1.5 166576 62740 ? Ss 2020 15:15 libsystemdsystemd-journald root 237 0.0 0.0 0 0 ? S root 259 0.0 0.0 45004 3416 ? Ss 2020 0:25 libsystemdsystemd-udevd root 476 0.0 0.0 0 0 ? S root 588 0.0 0.0 276244 2072 ? Ssl 2020 9:49 usrlibaccountsserviceaccounts-daemon message+ 592 0.0 0.0 42904 3032 ? Ss 2020 0:01 usrbindbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation root 636 0.0 0.0 65532 3200 ? Ss 2020 1:51 usrsbinsshd -D daemon 637 0.0 0.0 26044 2076 ? Ss 2020 0:00 usrsbinatd -f root 639 0.0 0.0 29476 2696 ? Ss 2020 3:29 usrsbincron -f root 643 0.0 0.0 20748 1992 ? Ss 2020 0:26 libsystemdsystemd-logind syslog 645 0.0 0.0 260636 3024 ? Ssl 2020 3:17 usrsbinrsyslogd -n root 686 0.0 0.0 773124 2836 ? Ssl 2020 26:45 usrsbinnscd root 690 0.0 0.0 19472 252 ? Ss 2020 14:39 usrsbinirqbalance --pid=varrunirqbalance.pid ntp 692 0.0 0.0 98204 776 ? Ss 2020 25:18 usrsbinntpd -p varrunntpd.pid -g -u 108:114 uuidd 767 0.0 0.0 28624 192 ? Ss 2020 0:00 usrsbinuuidd --socket-activation root 793 0.0 0.0 128812 3148 ? Ss 2020 0:00 nginx: master process usrsbinnginx -g daemon on; master_process on; www-data 794 0.0 0.2 133376 9120 ? S 2020 630:57 nginx: worker process www-data 795 0.0 0.2 133208 8968 ? S 2020 633:02 nginx: worker process www-data 796 0.0 0.2 133216 9120 ? S 2020 634:24 nginx: worker process www-data 797 0.0 0.2 133228 9148 ? S 2020 632:56 nginx: worker process web 955 0.0 0.0 36856 2112 ? Ss 2020 0:00 libsystemdsystemd --user web 956 0.0 0.0 67456 1684 ? S 2020 0:00 (sd-pam) root 1354 0.0 0.0 8172 440 tty1 Ss+ 2020 0:00 sbinagetty --noclear tty1 linux root 1355 0.0 0.0 7988 344 ttyS0 Ss+ 2020 0:00 sbinagetty --keep-baud 115200 38400 9600 ttyS0 vt220 root 2513 0.0 0.0 0 0 ? S 13:07 0:00 [kworkeru4:1] root 2587 0.0 0.0 0 0 ? S 13:13 0:00 [kworkeru4:2] root 2642 0.0 0.0 0 0 ? S 13:17 0:00 [kworker1:0] root 2679 0.0 0.0 0 0 ? S 13:19 0:00 [kworkeru4:0] root 2735 0.0 0.1 102256 7252 ? Ss 13:24 0:00 sshd: web [priv] web 2752 0.0 0.0 102256 3452 ? R 13:24 0:00 sshd: web@pts0 web 2753 0.5 0.1 14716 4708 pts0 Ss 13:24 0:00 -bash web 2767 0.0 0.0 29596 1456 pts0 R+ 13:24 0:00 ps aux root 10634 0.0 0.0 0 0 ? S Nov16 0:00 [kworker0:0] root 16585 0.0 0.0 0 0 ? S root 19526 0.0 0.0 0 0 ? S Nov16 0:00 [kworker1:1] root 28460 0.0 0.0 0 0 ? S Nov15 0:03 [kworker0:2] root 30685 0.0 0.0 36644 2760 ? Ss 2020 0:00 libsystemdsystemd --user root 30692 0.0 0.0 67224 1664 ? S 2020 0:00 (sd-pam) root 32689 0.0 0.0 47740 2100 ? Ss 2020 0:00 usrlocalilogtaililogtail root 32691 0.2 0.5 256144 23708 ? Sl 2020 1151:31 usrlocalilogtaililogtail 现在需要你统计VSZ,RSS各自的总和(以M兆为统计),输出格式如下 MEM TOTAL VSZ_SUM:3250.8M,RSS_SUM:179.777M
加载中...