I have to write an awk command that will find all lines in a specified file that are more than 30 characters long and split these lines into multiple lines with no more than 30 characters each.
I know I can find the length using
awk 'length>30' test.txt
But how to post-process the file and split each line?
For e.g. If my file is like this:-
qwertyuiopadfgghjkklkllllllvvvxxxx
jjjjfff
aaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
ggggggggggggg
dddddddddddddd
gggggggggggggggggggg
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
After running the command, it should be like this (with no line containing more than 30 characters):-
qwertyuiopadfgghjkklkllllllvv
vxxxx
jjjjfff
aaahhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhh
ggggggggggggg
dddddddddddddd
gggggggggggggggggggg
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaa