trim spaces in a file

Hi,
I'm new to shell programming. Need some help in the following requirement:

I have a file origFile.txt with values:
origFile.txt
.00~ 145416.02~ xyz~ ram kishor
.35~ 765.76~ anh reid~ kishna kerry

Now each row in the file has value for 4 columns with "~" as delimiter.
Now I need to erase the blank spaces between "~" and each column value. Also I need to remove the blank space between the begining of each line and the first column value.
The output file modFile.txt should look like
modFile.txt
.00~145416.02~xyz~ram kishor
.35~765.76~anh reid~kishna kerry

Could anyone please help me in writing the shell script for the same?

sed -e 's/\s*\~\s*/\~/g' -e 's/^\s*//g;' orig.txt

Cheers

echo "  .00~ 145416.02~ xyz~ ram kishor" | sed -e 's/[ ]*~[ ]*/~/g' -e 's/^[ ]*//'

Try this

cat origFile.txt | tr -d " " > modFile.txt

if your tilde is always followed by space

awk -F"~ " '{$1=$1}1' OFS="~" file

Whats the signifiance of [ ] and ( ) i have seen that in many people using it.

sed 's/[ ]*~[ ]*/~/g' yourfile

Thanks all of you.

If the origFile.txt has " " (space) value for any of the columns then the space is getting trimmed. e.g.
origFile.txt
.00~ 145416.02~ ~ ram kishor
.35~ 765.76~ anh reid~ kishna kerry

The output now looks like
modFile.txt
.00~145416.02~~ram kishor
.35~765.76~anh reid~kishna kerry

Is it possible to write a script which will give the o/p as
modFile.txt
.00~145416.02~ ~ram kishor
.35~765.76~anh reid~kishna kerry

Basically to leave a space between the delimiters if the value for the column is " " (space) i.e. ~ ~ instead of ~~