[opensuse 12.2 mantis] sed command -- how to

Greetings !!

I’m searching a way to delete all the spaces (0x20 '\ ’ caracters) from a file named map3.cssm.

It works with sed ‘s/\ //g’ map12x12/map3.cssm > map12x12/map003.cssm but I wanted to redirect the result displayed by sed to the file itself.

sed ‘s/\ //g’ map12x12/map3.cssm > map12x12/map3.cssm resulted to an emply file
sed ‘s/\ //g’ map12x12/map3.cssm >> map12x12/map3.cssm resulted to a double content !

220000000010
000022000000
200000000100
200030000000
000030001000
200300000050
000000010050
000030000050
004030100050
004030333050
004000000000
004004444000
220000000010
000022000000
200000000100
200030000000
000030001000
200300000050
000000010050
000030000050
004030100050
004030333050
004000000000
004004444000

How can I save the “seded” result to the file itself ?
And it there a way to apply this sed with a wildcard ?

*sed ‘s/\ //g’ map12x12/map.cssm
**
Thanx in advance !!

See “man sed”:

       **-i[SUFFIX]**, **--in-place**=SUFFIX]



              edit files in place (makes backup if SUFFIX supplied)



And it there a way to apply this sed with a wildcard ?

Yes. Just use a wildcard in the filename. Or you can also specify more than one file.

And you can always use a “for” loop of course.

GNU sed(1) has the i flag/option which is just like.

**sed 's/\ //g' map12x12/map3.cssm > tmpfile && mv tmpfile ** **map12x12/map3.cssm**

Which redirect to a tempfile and move back to the original file. So some folks would insist that sed is not a file editor because if the original file has a symlink then it might broke. Also a fifo is a secure way of making tempfiles e.g. not colliding with thesame file name within your local files.