我想在输出中出现logically moving media as follows...
后打印行。注意:此特定模式可以出现在文件中的任何位置。
请让我知道如何实现这一目标?
以下是我的档案:
Generating list of recommended changes ...
Proposed Change(s) to Update the Volume Configuration
=====================================================
Logically move media ID PN0960 (barcode PN0960L4) from standalone to slot 18.
Logically move media ID PN1067 (barcode PN1067L4) from standalone to slot 44.
Logically move media ID PN1080 (barcode PN1080L4) from standalone to slot 52.
Logically move media ID PN1711 (barcode PN1711L4) from standalone to slot 54.
Logically move media ID PN1728 (barcode PN1728L4) from standalone to slot 109.
Logically move media ID PN1926 (barcode PN1926L4) from standalone to slot 112.
Logically move media ID PN1933 (barcode PN1933L4) from standalone to slot 134.
Logically move media ID NY2617 (barcode NY2617L4) from standalone to slot 165.
Logically move media ID PN0016 (barcode PN0016L4) from standalone to slot 167.
Logically move media ID NY2011 (barcode NY2011L4) from standalone to slot 186.
Logically move media ID NY2021 (barcode NY2021L4) from standalone to slot 203.
Logically move media ID NY2046 (barcode NY2046L4) from standalone to slot 262.
Logically move media ID NY2222 (barcode NY2222L4) from standalone to slot 376.
Logically move media ID NY2236 (barcode NY2236L4) from standalone to slot 377.
Logically move media ID NY2290 (barcode NY2290L4) from standalone to slot 385.
Logically move media ID NY2519 (barcode NY2519L4) from standalone to slot 485.
Logically move media ID NY2017 (barcode NY2017L4) from standalone to slot 487.
Logically move media ID NY2048 (barcode NY2048L4) from standalone to slot 490.
Logically move media ID NY2133 (barcode NY2133L4) from standalone to slot 494.
Logically move media ID NY2135 (barcode NY2135L4) from standalone to slot 495.
Logically move media ID NY2149 (barcode NY2149L4) from standalone to slot 496.
Logically move media ID NY2348 (barcode NY2348L4) from standalone to slot 497.
Logically move media ID NY2371 (barcode NY2371L4) from standalone to slot 498.
Updating volume configuration ...
Processing existing media added to or moved within the robotic library by
logically moving media as follows...
Media ID Slot
======== ====
PN0960 18
PN1067 44
PN1080 52
PN1711 54
PN1728 109
PN1926 112
PN1933 134
NY2617 165
PN0016 167
NY2011 186
NY2021 203
NY2046 262
NY2222 376
NY2236 377
NY2290 385
NY2519 485
NY2017 487
NY2048 490
NY2133 494
NY2135 495
NY2149 496
NY2348 497
NY2371 498
Volume configuration successfully updated.
答案 0 :(得分:3)
或sed:
sed -n '/logically moving media as follows/,$p' input.txt
这将打印与文档末尾匹配logically moving media as follows
的所有行。
答案 1 :(得分:2)
此awk
是其中一种方式:
$ awk '/logically moving media as follows/ {p=1} p' file
查找"logically moving media as follows"
文字。找到后,标记p
会被{p=1}
激活。结束时p
条件为真,因此执行awk的默认行为,即{print $0}
。
它返回:
logically moving media as follows...
Media ID Slot
======== ====
PN0960 18
PN1067 44
PN1080 52
PN1711 54
PN1728 109
PN1926 112
PN1933 134
NY2617 165
PN0016 167
NY2011 186
NY2021 203
NY2046 262
NY2222 376
NY2236 377
NY2290 385
NY2519 485
NY2017 487
NY2048 490
NY2133 494
NY2135 495
NY2149 496
NY2348 497
NY2371 498
Volume configuration successfully updated.
答案 2 :(得分:2)
使用 fedorqui 的解决方案或:
sed -rn '/logically moving media as follows/,$p' file