[英]Its possible put a break line after grep?
I have the code like this:我有这样的代码:
scan-codes | grep -i '[!]\| url:\|started\|Aborted' | grep -v 'Effective\|style\|WARNING\|The version'
Output: Output:
[+] Started: Sat Feb 19 05:21:00 2022
| [!] 1 vulnerability identified:
| [!] Title: Cookie Notice & Compliance for GDPR / CCPA < 2.1.2 - Admin+ Stored Cross-Site Scripting
############## need break line here ##############
| [!] 1 vulnerability identified:
| [!] Title: WPBakery Page Builder < 6.4.1 - Authenticated Stored Cross-Site Scripting (XSS)
############## need break line here ##############
WARNING: Nokogiri was built against libxml version 2.9.10, but has dynamically loaded 2.9.12
And i want to put a break line (like \n) after grep. Its a scan, so i cant change the file.我想在 grep 之后添加一个换行符(如 \n)。这是一个扫描,所以我无法更改文件。
Suggesting to use single awk
script:建议使用单个
awk
脚本:
If matching combined 2 grep
conditions than print current line + newline every 2nd line:如果匹配组合 2
grep
条件而不是打印当前行 + 每 2 行换行:
awk '/\[!\]| url:|started|Aborted/ && !/Effective|style|WARNING|The version/ {ln++; print $0 (ln % 2) ? "\n": "";}'
/\[:\]| url:|started|Aborted/
/\[:\]| url:|started|Aborted/
Positive line matching condition !/Effective|style|WARNING|The version/
Negative line matching condition /\[:\]| url:|started|Aborted/
正线匹配条件!/Effective|style|WARNING|The version/
负线匹配条件
{ # For each line passing all conditions
ln++; # count printed line
newLineMaker = (ln % 2) ? "\n": ""; # New line marker any 2nd line
print $0 newLineMaker; # print
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.