我在我們公司的dhcp服務器的配置文件中添加了一長串主機。sed將第8個位置的空格字符替換爲選定的文本
的條目是這樣的:
host s1 { hardware ethernet b4:e1:0f:06:cb:83; fixed-address 192.168.10.43; }
host s2 { hardware ethernet b4:e1:0f:06:cb:90; fixed-address 192.168.10.64; }
host s3 { hardware ethernet b4:e1:0f:06:cb:9d; fixed-address 192.168.10.44; }
host s4 { hardware ethernet b4:e1:0f:06:cb:aa; fixed-address 192.168.10.65; }
host s5 { hardware ethernet b4:e1:0f:06:cb:b7; fixed-address 192.168.10.41; }
host s6 { hardware ethernet b4:e1:0f:06:cb:c4; fixed-address 192.168.10.35; }
host s7 { hardware ethernet b4:e1:0f:06:cb:d1; fixed-address 192.168.10.36; }
host s8 { hardware ethernet b4:e1:0f:06:cb:de; fixed-address 192.168.10.67; }
host s9 { hardware ethernet b4:e1:0f:06:cb:eb; fixed-address 192.168.10.72; }
我使用vim編輯文件。如何用類似.domain.com替換位置8處的空格字符? (我指的是空間焦炭S1後,S2等
我曾嘗試不同的配置和模式與SED,但由於某種原因,我不能」,它的工作。
的另一種方法是更換空間+ {與我想要的,但這不是我要尋找的解決方案。
問候,
SED -i的/ hardware/dom.com.hardware/g'file1 – chenchuk
您已添加vim作爲標籤。我能回答vim嗎? – SibiCoder
我想你可以...我真的不知道這是如何工作的... –