How to combine first,second and third fields in a file

Hi Guys,

I have a file as follows:

1     2 3

There are 5 spaces between 1 and 2 and one space between 2 and 3.

I want:

123

How can I do this using awk?

I tried using:

 
awk '$1=$1' file 

but it deletes all the spaces.

Thanks.

$ cat file
1     2 3

$ awk -v OFS="" '$1=$1' file
123

tr \   '\0' < file
123
$ echo "1     2 3" |sed 's/ //g'
123
tr -d " " < file

Sorry I gave incomplete information. Actually the file has something like this:


1     2 3 4 5 6 7   

I want:


123 4 5 6 7 

In other words, I want only the first three fields to be lumped together as one field leaving the remaining 4 fields intact.

sed 's/  *//;s/  *//' infile

Without being too clever:

$ awk '{print $1$2$3, $4, $5, $6, $7}' file1
123 4 5 6 7

hello ,

gaurav@localhost:/$ echo '1  2 3 4 5 6 7 '| perl -wlp -e 's/^(.)\s+(.)\s(.)(.*)$/$1$2$3$4/'
123 4 5 6 7 
gaurav@localhost:/$ 

Regards,
Gaurav.

That worked, Thanks.