January 04, 2009

UNIX case study - 8

remove two sequential double quotes but only when the the field is NOT null

I have a tab delimited file where each of the strings have double quotes.

The problem is that I have records which are in the following format:

"TEXAS" ""HOUSTON"" "123" "" "2625-39-39"
""MAINE"" "" "456" "I" "3737-39-82"

I would have to output another tab delimited file in the following fashion with the extra double quotes around the string removed:

"TEXAS" "HOUSTON" "123" "" "2625-39-39"
"MAINE" "" "456" "I" "3737-39-82"

This problem seems to persit across multiple fields and multiple rows.


http://tinyurl.com/98jdxv

1 comment:

  1. Anonymous6:33 AM

    perl -pe 's/(\S)""/$1"/g; s/""(\S)/"$1/g' file

    ReplyDelete

Note: Only a member of this blog may post a comment.