I'm trying to use the Unxutil sed to trim whitespace prior to EOL. The command I'm using is:
sed -e "s/ *$//g" temp.txt > temp2.txt
Files are CRLF under DOS. Is this my problem, that it's CRLF and it's looking for Unix EOL?
Okay, I got it. It's a platform difference (CRLF vs. LF).
sed -e "s/ *.$//g"
does work. The problem is that this coerces CRLF to LF. I've tried "sed -n p" and that displays to the screen correctly, but if I redirect it to an output file I still only get LF delimiting.
So long as I know a character that will be in every line of the file, I can pipe the sed output to NT "find" and it puts the correct EOL on the lines.
Any other thoughts?
Uh oh -- one more stray thought.
sed -e "s/ *.$//" only works so long as you know that the file *is* CRLF beforehand. If it's LF you're screwed b/c you wind up munging whatever the terminal character on the line is...
Are there parameters you can pass (under DOS) to specify or detect whether you have CRLF or LF delimited files?
I have been trying for the longest time to get sed to find the EOL. I just wanted to append some data to the end of every line of a file but I can never seem to get SED to understand the end of a line. Does the period dollar sign mean end of line in DOS?
This works for me: sed /$/hi/
Did you check your line endings, as described in the thread you replied to? I'm not sure what line endings my test file has.
Why not just use the character class [[:space:]]?
echo "line " | sed 's/[[:space:]]*$//g'
This will remove any and all spaces up to the EOL.