Reputation: 1644
Related: Add at the end of the line with sed
I looked at this question and tried all methods in the top answer; none of them worked. Every time when I try them and then open the file in Notepad++ it shows what I want to add (20 spaces) on a new line.
What I have:
word word number [EOL]
What I want:
word word number [EOL]
What I end up with currently:
word word number [EOL]
[EOL]
cat -vet
shows the the line ends with
number ^M$
The ^M doesn't print when using cat normally, so I'm guessing that's the issue.
So in short, how do I add spaces to the end of these lines programatically? I can use bash or powershell (would prefer bash).
Upvotes: 1
Views: 575
Reputation: 6420
^M
indicates that your file has DOS/Windows-style line endings. Run dos2unix
to convert it and then run one of the commands to append to the line again.
Upvotes: 1
Reputation: 247210
Your file may have DOS-style CR-NL line endings. So, try this sed command that will remove a carriage return (if present) and add the 20 spaces:
sed 's/\r\?$/ /'
Upvotes: 0