![grep 또는 sed를 사용하여 같은 줄에서 여러 일치 항목을 추출하는 방법](https://linux55.com/image/100586/grep%20%EB%98%90%EB%8A%94%20sed%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EA%B0%99%EC%9D%80%20%EC%A4%84%EC%97%90%EC%84%9C%20%EC%97%AC%EB%9F%AC%20%EC%9D%BC%EC%B9%98%20%ED%95%AD%EB%AA%A9%EC%9D%84%20%EC%B6%94%EC%B6%9C%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
다음과 같은 텍스트가 포함된 파일이 있습니다.
<TR><TD>5</TD><TD>Ukraine</TD></TR>
<TR><TD>3</TD><TD>Vietnam</TD></TR>
<TR><TD>3</TD><TD>Taiwan</TD></TR>
<TR><TD>3</TD><TD>Netherlands</TD></TR>
<TR><TD>3</TD><TD>South Korea</TD></TR>
<TR><TD>3</TD><TD>Great Britain</TD></TR>
<TD>
요소 간의 정보를 추출하고 싶습니다 .
5 Ukraine
3 Vietnam
3 Taiwan
3 Netherlands
...
답변1
이것을 확인하세요
$awk -F"[>|<]" '{print $5,$9}' input.txt
5 Ukraine
3 Vietnam
3 Taiwan
3 Netherlands
3 South Korea
3 Great Britain
sed 명령 사용
$ sed "s#<TR><TD>\(.\)</TD><TD>\(.*\)</TD></TR>#\1 \2#" input.txt
5 Ukraine
3 Vietnam
3 Taiwan
3 Netherlands
3 South Korea
3 Great Britain