Help for File Modification

Hi All, I have a file. This file contain huge amount of data. I want to modify this file. I want enter new line when count of "~ character is 79. Please find below the code : cat file_name | tr -d '\n' | sed 's/\([^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~[^~]*"~\)/\1\n/g' > new_filename This code is working. But sometime problem, not count properly. Please help me. Thanks in advance.

provide some example input contents

---------- Post updated at 04:48 PM ---------- Previous update was at 04:41 PM ----------

 
nawk -F~ 'BEGIN{RS="";OFS="~";count=0;}{for(i=1;i<=NF;i++){count+=1;if(count==73){printf("\n");count=0}else{printf("%s~",$i)}}}' input.txt

thanks itkamaraj, but this code also some problem. If i want only count ~ character (79 times). then what should i do.

change count==73 to count==79

hi itkamaraj, yes i know ,but your code not working properly.

provide sample data and required output

Actually file is huge volume of data