Remember : there is no need to use '-r' option under HP-UX. Those tests have been done on HP-UX. You must use '-r' with Linux. Here is the content of my file : - 1 line with 14 x '1', one space, one newline - 1 line with 14 x '2', one tabulation, one newline Controled with od : #od -c MyFile 0000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \n 0000020 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \t \n 0000040 Now we try with sed and the syntax that should work. Line one is correctly edited, line 2 not. It's normal as last character is a tabulation : #sed 's/[ ]*$//' Use special naming convention [:space:] wich means blankspace as '\s' in sed. #sed 's/[[:space:]]*$//' If Linux implementation of sed don't know [:space:] (well, it should ;-) it is a litle bit more verbose : #SPACE=`echo " \t\c"` #sed 's/['"$SPACE"']*$//'