Article 5MM8T How to find trailing spaces with sed?

How to find trailing spaces with sed?

by
lucmove
from LinuxQuestions.org on (#5MM8T)
I have a file that I know has a trailing space in some lines.
I thought I could remove them with sed:

Code:$ sed 's/ $//' file.txt > newfile.txtIt doesn't work. The trailing spaces are still there.

Maybe there is something wrong with my code. I spot a line that contains a trailing space:

Quote:
This line contains a trailing space.
Code:$ cat file.txt | sed '/ $/!d'That line is not present in the output. Never mind that line. Not one single line is in the output.

Well, maybe those are not trailing spaces after all. I know the file has been handled by someone who uses Windows. So maybe it is some other mysterious character?

So I manually edit the file and manually add trailing spaces, with my own Deluxe Linux-Compatible Space BarTM, to three random lines and save the file.

Code:$ cat file.txt | sed '/ $/!d'The output is still empty!

What am I doing wrong?

TIAlatest?d=yIl2AUoC8zA latest?i=q6vXlY6vlSY:er3ndshqkUo:F7zBnMy latest?i=q6vXlY6vlSY:er3ndshqkUo:V_sGLiP latest?d=qj6IDK7rITs latest?i=q6vXlY6vlSY:er3ndshqkUo:gIN9vFwq6vXlY6vlSY
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments