How to remove trailing spaces at the end of each line in a file on Linux? Use this script with sed:cat your_file | sed 's/[[:blank:]]+$//g' Related posts:How to remove trailing / in path in Bash? How to encode spaces in curl GET request URL on Linux? How to cut by multiple spaces in Linux? How to handle spaces in paths with rsync on Linux? How to put files with spaces in names into HDFS? Deleting a Specific Line From a Text File in Command Line in Linux Replacing tabs with spaces in Emacs How to process a file line by line in Python?