#!/usr/bin/awk -f # Copyright 2001 Blossom Associates West # All rights reserved. # Remove quotes from fields. # Basic unquote. # BUG: If a quoted field contains an escaped quote mark, this will not be handled correctly. # e.g. "quote with embedded "" mark" -> quote with embeded "" mark # i.e. the interior doubled quote mark is not made into a single quote mark. # e.g. "quote with embedded \" mark" -> quote with embeded \" mark # i.e. the back slash is not removed. function unquote0( x ) { if ( match( x, /^".*"$/ ) ) { x = substr( x, 2, length(x) - 2 ); } return x; } # Also converts internal doubled up quote characters to single quote characters. function unquote2( x ) { x = unquote0( x ); gsub( "\"\"", "\"", x ); return x; } # Also converts quote characters escaped with a backslash to just that character. function unquote3( x ) { x = unquote0( x ); gsub( "\\\"", "\"", x ); return x; } function unquote( x ) { return unquote0(x); } { for ( i = 1; i <= NF; i++ ) { $i = unquote2( $i ); } print; }