To trim leading spaces
string=`echo $string | sed -e 's/^ *//g'`
echo string=$string
To trim trailing spaces
string=`echo $string | sed -e 's/ *$//g'`
echo string=$string
Some times you cannot rely on ‘rm’ command for deleting huge number of files. Even ‘-f’ switch will fail you. In those situations the following command can be used.
find . -name '*.ext' | xargs rm