File Modification

Hi, I have a file input.txt. cat input.txt output is as follows : Code: "0001"~"name"~"bb"~"20.25"~""~""~"0002"~"name" "dd"~"35.50"~"" ~""~"0003"~"name"~"aa"~"21.3 5"~""~""~ I want the output looking like: cat output.txt Code: "0001"~"name"~"bb"~"20.25"~""~""~ "0002"~"name""dd"~"35.50"~""~""~ "0003"~"name"~"aa"~"21.35"~""~""~ I have a script. Code: cat input.txt | tr -d '\n' | sed 's/\("name"\)/\1\n/g' > output.txt here I have to check "name" string and then enter newline. But I want the output as above. Anyone can help me please. Thanks in advance

@mnmonu: Please use code-tags. Unable to understand the layout of your input file and your desired output.

I want the output looking like:
cat output.txt
Code:

cat input.txt | tr -d '\n' | sed 's/~\(\"[0-9]\{4\}\)/~\n\1/g'

Hi balajesuri,

your script is correct, but if input file looking like

and output

then your script not execute properly

This is what happens if you keep changing requirements over posts. Regex pattern is sed was crafted as per your first requirement.

cat input | tr -d '\n' | sed 's/\(\"~\"\"~\)\(\"0\)/\1\n\2/g'

Actually file data may be change, but in first line no like "0001" ; and the string "name" not change.
if count ~ character >6 then new line print,that is the better way.