我想打印路由器配置並僅排序以模式「crypto isakmp key 6」開頭的行。重要的是,我想在同一個地方留下這些行,所以在這行之前和之後應該保持在同一個地方(不排序)。BASH排序行以模式開始
例CFG文件:
123 345
678 901
bla bla bla
ble ble ble
crypto isakmp key 6 kokofeofepokpfowkfpwjeiofjwiojefiow address 123.456.789.012
crypto isakmp key 6 ofjwiojefiow352okdwofkwkfi9i42kpfsej09f09j4 address 123.456.789.012
crypto isakmp key 6 9i42kpfsej09f09j4ofjwiojefiow352okdwofkwkfi address 123.456.789.012
crypto isakmp key 6 9j4ofjwiojefiow352okdwofkwkfi9i42kpfsej09f0 address 123.456.789.012
ccc ddd eee
fff ggg hhh iii
123 456
所以首先我想打印不變(行的隨機數):
123 345
678 901
bla bla bla
ble ble ble
然後我想打印SORTED線開始加密ISAKMP密鑰6.
最後我想打印其餘文件不變(也是隨機數行):
ccc ddd eee
fff ggg hhh iii
123 456
我已經被很多操作,包括獲取第一個和最後的位置「加密ISAKMP密鑰6」,用尾/頭命令管理這一點,但它是相當複雜的,我不知道是否有選項AWK/SED可能是其他Linux工具來管理它的指定行。請解釋你的命令在步驟中做了什麼。
預期輸出(密碼排序其餘完好):
123 345
678 901
bla bla bla
ble ble ble
crypto isakmp key 6 9i42kpfsej09f09j4ofjwiojefiow352okdwofkwkfi address 123.456.789.012
crypto isakmp key 6 9j4ofjwiojefiow352okdwofkwkfi9i42kpfsej09f0 address 123.456.789.012
crypto isakmp key 6 kokofeofepokpfowkfpwjeiofjwiojefiow address 123.456.789.012
crypto isakmp key 6 ofjwiojefiow352okdwofkwkfi9i42kpfsej09f09j4 address 123.456.789.012
ccc ddd eee
fff ggg hhh iii
123 456
問候, 邁克
發佈排序的行以及。分類什麼? – 123
顯示完整的預期輸出,而不僅僅是輸入的頂部和底部以及關於中間的說明。 –