假设我有以下输入文件:
Server 'Test AB'
option type 'ss'
option port '1234'
option timeout '60'
Server 'Test CD'
option type 'ss'
option port '1234'
option timeout '60'
Server 'Test EF'
option type 'ss'
option port '1234'
option timeout '60'
Server 'Test GH'
option type 'ss'
option port '1234'
option timeout '60'
Run Code Online (Sandbox Code Playgroud)
现在我想使用 sed 将“选项端口'1234'”与“选项端口'9876'”交换,但我只想为服务器“Test EF”执行此操作。所有其他端口应保持不变。
输出应如下所示:
Server 'Test AB'
option type 'ss'
option port '1234'
option timeout '60'
Server 'Test CD'
option type 'ss'
option port '1234'
option timeout '60'
Server 'Test …Run Code Online (Sandbox Code Playgroud)