-1

Sometimes, when passing the name of files from a config.txt into a pipe, I get weird problems of non-existing files. I fear it is due to some non-standard end of line characters. I am using kate as standard IDE, the end of line should simply be \n.

How can I remove the unwanted characters and assure that each line terminates with \n using bash?

Thank you

Gigiux
  • 475
  • 6
  • 16
  • 1
    What characters? If the character isn't one of `\r` or `\n`, it's not an end-of-line character any more than `X` or `4` is an end-of-line character. – Andrew Henle Dec 22 '20 at 11:20
  • 1
    Do you have a file that will reproduce the problem? Then please [edit] your question and show both the content of the file and output of `od -c your_file` – Bodo Dec 22 '20 at 11:33
  • You might find help in [How to test whether a file uses CRLF or LF without modifying it?](https://unix.stackexchange.com/q/79702/315749) and [What is `^M` and how do I get rid of it?](https://unix.stackexchange.com/q/32001/315749). Chances are your question turned out to be a duplicate of the latter. – fra-san Dec 22 '20 at 11:48
  • the ^M is probably the problem, even if I don't use windows and I can't see any strange character. But if I switch from Kate to Gedit, the error disappeared. Tx – Gigiux Dec 24 '20 at 07:51

1 Answers1

1

try dos2unix or d2u. If this does not work, then you will have to tell us more about what the characters are.

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102