How to remove trailing whitespaces with sed?

后端 未结 10 886
我在风中等你
我在风中等你 2020-11-28 21:49

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)?

<         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 22:18

    At least on Mountain Lion, Viktor's answer will also remove the character 't' when it is at the end of a line. The following fixes that issue:

    sed -i '' -e's/[[:space:]]*$//' "$1"
    

提交回复
热议问题