답변1
다음 내용으로 실행 가능한 스크립트 test.awk를 만듭니다.
awk '
# { system( "echo \"" $0 "\" >&2") }
BEGIN { R = "\"" }
/^###/ {
sub(/\n$/,"",R)
print R "\""
R = "\""
next
}
{
sub(/\n$/,"")
gsub(/"/,"\"\"")
R = R $0 "\n"
}
' $@
그런 다음 실행
test.awk longfile.txt > longfile.csv
libreoffice Calc를 사용하여 longfile.csv를 엽니다.
긴 파일.txt:
dkdkdkdk
qsdfqlsdf
qsdfjqlsdf
######
qdfqj
qsdfmlkjqsd
qsiapriopazeiru
wqsdfqesr
######
rurururururururuur
rururururururururu
ururururururururur
######
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
######
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
######
긴 파일 .csv:
"dkdkdkdk
qsdfqlsdf
qsdfjqlsdf"
"qdfqj
qsdfmlkjqsd
qsiapriopazeiru
wqsdfqesr"
"rurururururururuur
rururururururururu
ururururururururur"
"iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii
iiiiiiiiiiii"
"uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu
uuuuuuuuuuu"