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.
这完美地工作:
awk '{for (i=1;i<=NF;i++) if($i ~/mystring/) print $1, $i}'
但我也想打印远离 $i 字段的第二个字段。
想法?
相当简单:)
awk '{for (i=1;i<=NF;i++) if($i ~/mystring/) print $1, $i, $(i+2)}'