Remove trailing spaces at the end of each line in a file Posted on Mar 24, 2018 by Q A In QA 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' Read more: 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? Replacing tabs with spaces in Emacs How to put files with spaces in names into HDFS? Deleting a Specific Line From a Text File in Command Line in Linux How to process a file line by line in Python?