I need a help. I am pretty new to the shell level programing. I was trying to split a long lines to a multiple lines with few conditions. I goggle for the code and found some snippets and tried to modified it but I got few strange problems too.
I have to split the lines if line is longer than 120 characters, then I have to separate it by adding "\" at the end of around 120th character. Note it can only separated at delimitation positions such as space or comma. And here is the code for that
if ( length($0) > 120 )
while(length(str) > 120)
for (m=1; m<=120;m++)
if( letter !=",")
# printf("%s\n",substr($0,i+1,j) );
if( letter !=" ")
if( length(str) > 1 )
printf("%s\n", substr(str,2,length(str))) ;
But my problem was that above condition is working if put in posted order. If I used to work with equal to and put the expression after then it is not working properly.
I was also not able to use the OR expression for comma and space
I also need the program which can revert the same operation. I also read few tutorial about sed but found its quite confusing for new users