I have a simple shell script that removes trailing whitespace from a file. Is there any way to make this script more compact (without creating a temporary file)?
sed 's/[ \t]*$//' $1 > $1__.tmp
cat $1__.tmp > $1
rm $1__.tmp
Thanks to codaddict for suggesting the -i
option.
The following command solves the problem on Snow Leopard
sed -i '' -e's/[ \t]*$//' "$1"