gpt4 book ai didi

linux - 如何正确循环这个 BASH 语句?

转载 作者:太空狗 更新时间:2023-10-29 11:19:47 26 4
gpt4 key购买 nike

在我编写的这行代码中,最好的循环是什么,它遍历日志文件并找到 $6 中失败的行?对 BASH 和 LINUX 很陌生,无法使任何循环正常工作。

Sep 13 12:09:39 icarus sshd[14043]: Failed none for invalid user 55659
Sep 13 12:09:43 icarus sshd[14043]: pam_unix(sshd:auth): check pass; user unknown
Sep 13 12:09:43 icarus sshd[14043]: pam_unix(sshd:auth):
Sep 13 12:09:44 icarus sshd[14043]: Failed password for invalid user 55659
Sep 13 12:09:48 icarus sshd[14043]: pam_unix(sshd:auth): check pass; user unknown
Sep 13 12:09:50 icarus sshd[14043]: Failed password for invalid user 55659 from

示例命令

cat auth.log | sed -e 's/,//g' | awk -F" " '{print $6}'

最佳答案

$ grep Failed auth.log
Sep 13 12:09:39 icarus sshd[14043]: Failed none for invalid user 55659
Sep 13 12:09:44 icarus sshd[14043]: Failed password for invalid user 55659
Sep 13 12:09:50 icarus sshd[14043]: Failed password for invalid user 55659 from

关于linux - 如何正确循环这个 BASH 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14847027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com