stripping white space...

Hi All;

Having a problem with a file..

the file contains the following data... (a snapshot)

1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50
186FDF93E1303DBA217279EC3671EA91,NG5 1JU,M,24
3783FFAF602015056A8CD21104B1AAAF,CH42 4NQ,M,17

It has 3 columns sepreated by a ,
the second column as a space in the middle of it..

1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50
I want to run a script against the file to strip that white space. Not really where to start.

Any pointers will greatly appericated

Thanks

awk 'BEGIN{OFS=FS=","}{ gsub(" ","",$2) }1' "file"

Hi

Thanks very much for the prompt reply.. I tried running the command you gave me on command line I'm getting a few errors

> awk 'BEGIN{OFS=FS=","}{ gsub(" ","",$2) }1' "user.db"
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
>

I'm running on solaris 9.

As always...... use 'nawk' instead of plain old 'awk' on Solaris...

Gentlemen,

I'm humbled by your knowledge :slight_smile:

U can Try this also!!!!!!!!!!!!!!!!!!!!!!!!!

cat filename | tr -s ' ' ','

Regards,
aajan

hey i have taken one line of your test file as follows,
var1="1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50"
then
echo $var1 | tr -d " "
o/p:1331F9E9DB7C2BB80EAEDE3A8F043B94,AL71DZ,M,50

surely it might help you out, if a blank space/tab is there .

no need for cat

tr -s .... < filename