sed命令

原文

interface eth-0-11
 description ct:TengXun-11
interface eth-0-12
 description ct:TengXun-12
interface eth-0-13
 description ct:TengXun-13
interface eth-0-14
 description ct:TengXun-14
interface eth-0-15
 description ct:TengXun-15
interface eth-0-16
 description ct:TengXun-16
interface eth-0-17
 description ct:TengXun-17
interface eth-0-18
 description ct:TengXun-18
interface eth-0-19
 description ct:TengXun-19
interface eth-0-20
 description ct:TengXun-20

命令及结果

cat aa.txt|sed  -r 's/ct:(.*)/\1-OC1-60G-N/g'
interface eth-0-11
 description TengXun-11-OC1-60G-N
interface eth-0-12
 description TengXun-12-OC1-60G-N
interface eth-0-13
 description TengXun-13-OC1-60G-N
interface eth-0-14
 description TengXun-14-OC1-60G-N
interface eth-0-15
 description TengXun-15-OC1-60G-N
interface eth-0-16
 description TengXun-16-OC1-60G-N
interface eth-0-17
 description TengXun-17-OC1-60G-N
interface eth-0-18
 description TengXun-18-OC1-60G-N
interface eth-0-19
 description TengXun-19-OC1-60G-N
interface eth-0-20
 description TengXun-20-OC1-60G-N
posted @ 2022-03-09 10:17  lifei888  阅读(18)  评论(0编辑  收藏  举报