How do you remove blank spaces at the end of a line in Linux?

Khánh Đoan

New member
How do you remove blank spaces at the end of a line in Linux?
Answer
Remove just spaces: $ sed ‘s/ *$//’ file | cat -vet – hello$ bye$ ha^I$ # tab is still here! Remove spaces and tabs: $ sed ‘s/[[:blank:]]*$//’ file | cat -vet – hello$ bye$ ha$ # tab was removed!
 

Tìm kiếm

Back
Top