Delete spaces in between fields

I am new to unix and need some assistance.

I have a file in the format below with about 15 fields per each record. I have 2 records displayed below.

"1234","Andy ","Rich ","0001","123 Main Street ","Dallas "
"2345","Andrew ","Richter ","0002","234 First Ave ","Kirby "

My Final output needs to be as follows

"1234","Andy","Rich","0001","123 Main Street","Dallas"
"2345","Andrew","Richter","0002","234 First Ave","Kirby"

I am sure I can use the sed command but not sure what parameters to use. Any and all assistance would bve highly appreciated.

Thanks

Try using the 'tr' option - this is replacing any string to anything u want
at your case you need to replace <SPACE>" with "
the syntax should be somthing like: | tr ' ' '"'
this will replace the space with quote ""

thanks for yoru resposne but I am totally new to sed and unix, would it be possible for you to give me the entire sed command that i can try.

Btw, i did try the sed command that I am typing below and it deleted every space even in between for e.g the original data was "123 Main Street" and after the command I used it became "123MainStreet".

This is the command I use

sed -e "s/[' ']*"/"/g" $filea > $fileb

Thanks

sed -e 's/[ ]"/"/g' oldfile>newfile

how would this alone suffice ?...

output of your command,

echo "1234","Andy ","Rich ","0001","123 Main Street ","Dallas " | sed -e 's/[ ]"/"/g' 
1234,Andy ,Rich ,0001,123 Main Street ,Dallas

double quotes " needs to be preserved

try this,

echo "1234","Andy ","Rich ","0001","123 Main Street ","Dallas " | sed -e "s/[' ']*,/,/g" -e 's/,/\",\"/g;s/^/\"/;s/$/\"/'

complicating the uncomplicated things.....
sed -e 's/"/"/g' inputfile>outputfile...
in case u have read the request is to act on file and not on echo statemtn...
as for info ...echo removes the double quotes..treating them as double quoted expression for echo command.....

awk '{ gsub(/ +","/, "\",\""); print }' infile >outfile

you are correct,

but wouldn't be even more precise if the command is

sed -e 's/[ ]*"/"/g' inputfile>outputfile...

yah....but as in the file was contaning one space before "...but yah it would be better as sed -e 's/[ ]*"/"/g' inputfile>outputfile

Thanks to all of you, I do not have words to express.

Hopefully I can make contribution one day too

Hello Again,

One little change, hopefully this would be an easy one.

The very data element in my file is "1" or "space" and I need this space in the very last field.

I am sure all of you can come up with a solution.

thanks

can u provide the data..and by example what u really want.....can't get urs requirements

Here is my data

I have a file in the format below with about 15 fields per each record. I have 2 records displayed below.

"1234","Andy ","Rich ","0001","123 Main Street ","Dallas ", "1"
"2345","Andrew ","Richter ","0002","234 First Ave ","Kirby ", " "

My Final output needs to be as follows

"1234","Andy","Rich","0001","123 Main Street","Dallas","1"
"2345","Andrew","Richter","0002","234 First Ave","Kirby"," "

I am using the following Sed command and it works excep it also deletes the space in the field and I need the last data element to stay like it is either a "1" or a " " (space).

sed -e 's/[ ]"/"/g' inputfile>outputfile...

what do I need to change in the sed command that I am using to get the result that I am looking for. The above is just the sample of the data, and it is not all data elements, there are quite a few additional fields but the last field is what I have in my data sample.

Thanks