我想删除出现在 awk 输出中的引号(双引号),如何实现
# systool -c fc_host -v | awk '/Class Device =/{host=$4}/port_state/{print host,$3}' (This is my awk output sorted)
"host1" "Online"
"host2" "Online"
Run Code Online (Sandbox Code Playgroud)
下面是命令和命令输出..
# systool -c fc_host -v
Class Device = "host1"
Class Device path = "/sys/class/fc_host/host1"
active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "
fabric_name = "0x100000051ee8aecf"
issue_lip = <store …
Run Code Online (Sandbox Code Playgroud) 我有类似于下面给出的示例的日志,我只是SUCCESS
在日志文件中查找一个字符串并计算总数。
$ cat ansible.log
lnx-host01.tin.com | SUCCESS => {"changed": false, "ping": "pong"}
lnx-host02.tin.com | SUCCESS => {"changed": false, "ping": "pong"}
Run Code Online (Sandbox Code Playgroud)
这是一种简单明了的方法,但我想知道是否可以将awk
其作为单行代码来完成,而无需传递给wc
命令。
$ awk '/SUCCESS/{print $0}' ansible.log | wc -l
66
OR
$ awk '/SUCCESS/' ansible.log| wc -l
66
Run Code Online (Sandbox Code Playgroud) awk ×2