$ awk 'length > 72' {HOW TO PRINT THE LINEs IN PCS?} msg
ie I want it to add \n
after 72 chars and continue, so initially you may need to remove all single \n
s and the add them. It may be easier be easier with other tool but let's give a try to awk.
[Update]
Williamson provided the right answer but some help needed to read it. I break the problem into parts with simpler examples, below.
Why does the code below print
\t
in both cases,gsub
should substitute things? x is a dummy-file, some odd 0 at the end.Attacking the line
line = $0 \n more = getline \n gsub("\t"," ")
in Williamson's reply,line
apparently gets whole stdout whilemore
gets popped value of$0
, right?
Code to part 1
$ gawk '{ hallo="tjena\t tjena2"; gsub("\t"," "); }; END {print hallo; gsub("\t", ""); hallo=hallo gsub("\t",""); print hallo }' x
tjena tjena2
tjena tjena20
prt -e -t
or similar to convert tabs to relative blanks first? Should newlines really be removed as suggested in the question or replaced with blanks? etc., etc.) and concise, testable sample input and expected output.\t
s because you aren't runninggsub("\t"," ")
on the variable you're printing,hallo
, you're running it on$0
which you aren't printing.