쉘 스크립트를 이용하여...
텍스트 파일의 불규칙적인 줄간격을 1줄로 일정하게 하고 싶습니다. [ 줄간격이 1줄, 2줄, 여러 줄로 되어있습니다. ]
어떤 방식으로 하면 될까요??
sed를 이용하면 되나요?? 답변 부탁드리겠습니다.
처리하고자하는 텍스트 파일 = in.txt 결과 = out.txt
cat의 -s 옵션이용, -s, --squeeze-blank suppress repeated empty output lines
1. cat -s in.txt > out.txt
문제점: 스페이스, 탭 등 화이트스페이스만 있는 빈줄은 빈줄로 처리되지 않음
2. cat in.txt | sed 's,^\s*$,,' | cat -s > out.txt
답변 감사드립니다.
감사인사가 늦었네요...
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
처리하고자하는 텍스트 파일 = in.txt 결과 =
처리하고자하는 텍스트 파일 = in.txt
결과 = out.txt
cat의 -s 옵션이용,
-s, --squeeze-blank
suppress repeated empty output lines
1. cat -s in.txt > out.txt
문제점: 스페이스, 탭 등 화이트스페이스만 있는 빈줄은 빈줄로 처리되지 않음
2. cat in.txt | sed 's,^\s*$,,' | cat -s > out.txt
답변 감사드립니다.
답변 감사드립니다.
감사인사가 늦었네요...
댓글 달기