2017-03-23 2 views
0

텍스트 파일을 편집하고 있습니다 (제 경우에는 JMeter XML입니다). ed를 사용하여 XML의 첫 번째 줄과 마지막 줄을 나타내는 두 줄을 찾습니다. 섹션.ed 행 편집기를 사용하여 두 검색 일치 사이의 줄을 삭제하는 방법

두 검색 일치 사이의 줄을 어떻게 삭제할 수 있습니까?

예제 파일 :

1 <hashTree> 
2 <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true"> 
3 <stringProp name="ConstantTimer.delay">300</stringProp> 
4 </ConstantTimer> 
6 </hashTree> 

과 내가 2-4가 포함 된 행을 삭제하려고합니다.

답변

2

당신이 그들 모두를 수행하려는 경우를 사용하여 두 마크 사이 삭제를 수행 할 수 있습니다,

g/<hashTree>/+,/<\/hashTree>/-d 

이 모든 <hashTree> BLO를 가정합니다주의 : 다음 다음 다음 줄에서 시작 닫는 태그 앞으로 검색, 뒤로 이동 -를 사용하도록 +를 사용하고, 결과의 컨텐츠를 삭제 ck에는 일부 콘텐츠가 삭제됩니다. 빈 블록이 있으면 원하는 것보다 많은 내용을 삭제할 수 있습니다.

0

당신은 당신이 시작을 찾기 위해 g 명령을 사용할 수 있습니다, 당신이 찾을 줄을 표시하고 다음 코드

1     <---- Jump to line 1 
/ConstantTimer  <---- Search for the first 'ConstantTimer' 
kx     <---- Mark it as 'x' 
/ConstantTimer  <---- Search for the second 'ConstantTimer' 
ky     <---- Mark it as 'y' 
'x,'yd    <---- delete between the two marks 'x and 'y 
w     <---- save the changes 
q     <---- quit ed