tr command

Im using "#! /bin/sh" and i want to use a script to change the output of another program.
How do i convert multiple spaces to a single space? ive tried using tr -s " " but it doesnt seem to work!
Anyone know whats wrong?

You have to escape the any special character - the following will remove the extra spaces

$ cat junk|tr -s '\ '

where junk is a file with some extra spaces in it - be aware it does it for the whole file so if there is something that needed more than one space, it will be removed down to one also.

I'm sure the experts in sed will post to this to give you a better way to do it.

tr -s " "
tr -s '\ '
tr -s ' '

all work the same for me on HP-UX and SunOS. But anyway the sed command is:

sed 's/  */ /g'

And, careful, there are two spaces before the asterisk.