Trim trailing spaces from each line in a file

Hello folks,
Is there a simple way to trim trailing spaces from each line a file. Please let me know.

Regards,
Tipsy.

sed 's/[ ]*$//' old > new

One more thing.

add a \t to the "[ ]" set to include tabs

Thanks tmarikle.

Regards,
Tipsy.

hi,

The following can be accomplised using Perl script also

[code]
open(i,"<$filein") || die "Can't open $!\n ";
while (!eof(i)) {
$line = <i>;
push @temp, $line;
}
close(i);

foreach $line(@temp) {
$line =~ s/\s+$//o;
}
[\code]

Thanks,
Raj

In Python, if you have it:

>>> for lines in open("yourfile.txt"):
>>>      print  lines.strip()