Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在日志文件中搜索一些单词并仅显示文件中这些行中给定的列号。 例如:我想在 abc.log 中搜索“word”并打印第 4,11 列
grep "word" abc.log | awk '{print $4}' | awk '{print $4}'
但这不能锻炼有人可以帮忙吗
您需要将$4and$11一起打印,而不是管道$4到另一个awk.
$4
$11
awk
另外,你不需要grep因为awkcan grep。
grep
试试这样:
awk '/word/{print $4,$11}' abc.log