Delete whitespace

Hi,

I have been trying to remove whitespace from a file using sed. Here is an example of what im trying to do:

www1 = www1
www2 = www2
www3 = www3
and all the way to 300 and i want it to look like:

www1=www1
www2-www2
www3=www3
again upto 300

Any help regarding this would be greatfully appreciated
Thanks in advance :b:

what exactly have you tried?

i new at this so hav been tryin everythin i can find by googling the problem

#sed 's/ //g' oldfile > newfile

#sed '$s/ \+//g' oldfile > newfile

and quite a few others similar to this.
one thing that did seem strange is if i do the first one i mentioned it will do the top line i.e www1=www1 but all the rest of the lines remain the same but if i again do the first one i mentioned but do
#sed 's/www/hello/g' oldfile > newfile
it successfully changes all the www's to hello.
In my books thats strange but like i said im a newbie

Thanks for your swift response :smiley:

sed '%s/ *= */=/g' oldfile > newfile

i hav just tried this and it gives the following error message:

sed: -e expression #1, char 1: unknown command: `%'

Thanks again:D

strange.........

sed '1,$s/ *= */=/g' oldfile > newfile

this has again only done the top line i.e:

www1=www1
www2 = www2
www3 = www3

thanks for tryin :smiley:

sorry i didnt realise i didnt put this but there are actually 5 spaces behind each = and six spaces after

cheers

VERy strange.. worked just fine under Solaris' stock sed....
Are these 'white spaces' 'space' or TAB (or something else)?

they are 'spaces' and i am using Red Hat 3.4.6-3

cheers :b:

Are you sure you're doing this?:

sed '1,$s/ *= */=/g' oldfile > newfile

yep definately i have just tried it again triple checking everything and it still of changes the top line

Cheers :b:

Hi the problem was that one of the commands i used earlier seems to have converted it from tab to spaces and now that i reverted to the original it has gone back to tabs hence removing spaces was not working. in the end i used:
in vi
:%s/\t//g

thanks for the speed of your replys it was greatly appreciated

cheers :smiley: