- 论坛徽章:
- 18
|
回复 2# wh7211
谢谢您的帮助。可是我的awk版本比较低,是3.1.7。
┌─[Mon May 14 14:56:50 CST 2018]
└─[root@apaciprtac:/tmp]# awk '/^THRESHOLD/||/^CRITICAL/||/^CURRENT/{a[$2]=$0;next}/^-/{PROCINFO["sorted_in"]="@ind_num_desc";for(i in a){print a};delete a}1' file
SERVER: 135.240.144.16
USER: 1ls
THRESHOLD: 100 G
CURRENT: 70.30 G (75488632832 Bytes) available
CRITICAL: 50 G
-----------------------------------------------------------------------------
SERVER: 135.240.146.254
USER: 1ls
THRESHOLD: 100 G
CURRENT: 426.59 G (458046586880 Bytes) available
CRITICAL: 50 G
-----------------------------------------------------------------------------
┌─[Mon May 14 14:56:57 CST 2018]
└─[root@apaciprtac:/tmp]# awk --version
GNU Awk 3.1.7
Copyright (C) 1989, 1991-2009 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
┌─[Mon May 14 14:57:04 CST 2018]
└─[root@apaciprtac:/tmp]#
在这个awk版本下您的命令不能得到正确的结果。
请问应该如何修改才能在awk 3.1.7下得到正确的结果呢?
谢谢!
|
|