다음에 추가 to the bottom of a html file?

다음에 추가 to the bottom of a html file?

HTML 파일이 많이 있는데 <script src="ga.js"></script>각 검색 인스턴스 앞에 ""를 추가 해야 합니다 </body></html>.

이 모든 파일의 맨 아래에 어떻게 추가합니까?

답변1

실제로 같은 줄에 있으면 다음을 사용하여 쉽게 할 수 있습니다 sed.

$ sed -i '/<\/body><\/html>/ i <script src="ga.js"></script>' *.html

현재 디렉터리에서 모든 html 파일을 찾아( *.html), 검색 </body></html>( /.../)하고, i그 앞에 스크립트 태그를 삽입( )하고, 변경 사항을 동일한 파일에 다시 씁니다( -i).

관련 정보