![파일에서 빈 줄을 제거하는 방법은 무엇입니까? [복사]](https://linux55.com/image/92560/%ED%8C%8C%EC%9D%BC%EC%97%90%EC%84%9C%20%EB%B9%88%20%EC%A4%84%EC%9D%84%20%EC%A0%9C%EA%B1%B0%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
답변1
텍스트 사진을 게시하지 말고 터미널에서 질문에 복사하여 붙여넣으세요.
빈 줄을 필터링하는 방법에는 여러 가지가 있습니다. 가장 간단한 두 가지는 다음과 같습니다.
그리고 grep
:
grep -v '^$' /path/to/input > /path/to/output
그리고 sed
:
sed '/^$/d' /path/to/input > /path/to/output
sed --in-place '/^$/d' /path/to/input # modify the file rather than creating a new one