How to generate a pipe ( | ) delimited file?

:)Hi Friends,

I have certain log files extracted. I want it to be converted in pipe ( | ) delimited file. How do i do it?

E.g.

Account Balance : 123456789 Rs O/P (Account Balance: | 123456789 Rs)
Account Balance (Last) > 987654321 Rs O/P (Account Balance (Last) | 987654321 Rs)
Last update = 21/09/2008 5.30 PM O/P (Last update = | 21/09/2008 | 5.30 | PM)

:eek:Now the real complication is, it can be anything apart from above mentioned example. So it would be great help if you explain the script a bit so that I can write it as I want.

Is it possible?
If yes,
Requesting you to guide me to write a "Simple" script.
Wold appreciate if you explain it briefly as well :stuck_out_tongue:

Bye
Anushree

Usually you can use something like 'sed -e "s/[:>]/|/g" -e "s/=/= |/g" filename' but your "/2008 | 5.30 | PM" can't be anchored since it doesn't follow any replacement rules. Maybe somebody can whip up a better example if you provide more elaborate replacement rules...

what's your rules?
If you do not have rules, nobody can do it.

How are the fields delimited in the file?

If the separator is any of the :, >, and =, use awk, with FS set to a pattern that matches all three:

awk -F '[:>=]' '
   BEGIN { OFS = "|" }
         { $1 = $1; print }
' LOGFILE

existing delimiter is "Sapce"

$ cat buf | tr -s ' ' '|'
Account|Balance|:|123456789|Rs|O/P|(Account|Balance:|123456789|Rs)
Account|Balance|(Last)|>|987654321|Rs|O/P|(Account|Balance|(Last)|987654321|Rs)
Last|update|=|21/09/2008|5.30|PM|O/P|(Last|update|=|21/09/2008|5.30|PM)

Is that what you want ?