Discussion:
[OT] add carriage return to text files
(too old to reply)
dale
2017-02-19 22:41:51 UTC
Permalink
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows

any ideas? probably could do an awk file on each, that would save some time

want to do them in a batch all at once, guess I could do a bash script
of awk conversions

if someone has already done this, or knows how, would you point me in
the right direction?

tried to google some ...
--
dale | http://www.dalekelly.org
Kaz Kylheku
2017-02-19 23:54:03 UTC
Permalink
Post by dale
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows
Learn real editor.

Vim:

:set fileformat=dos
:w

File now saved with CR-LF line endings. Next time you open the file,
Vim will automatically use this fileformat setting.

If you you are just simply using a shared folder between Linux and
Windows, or copying the files back and forth, consider just keeping the
files in Windows format. If Octave and Gnuplot on Linux don't mind
the CR's, you're just fine. Edit in a decent editor and you won't
see the line endings.

Regarding conversion, the manpage for "unix2dos" and "dos2unix".

Another thing: you should consider putting your files into a
cross-platform version control system like Git. A version control system
can create a working copy of text files in the local operating system
format.

You can make a change on Windows to your Octave or Awk code,
commit the change, then push it out to your Linux-side repository
where the update is seen in Unix format.

No software developer worth their salt performs conversions on
their maintained source code between Unix and Windows. Version
control takes care of it.

I wouldn't develop anything other than throwaway code without version
control.
dale
2017-03-04 17:01:16 UTC
Permalink
Post by Kaz Kylheku
Post by dale
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows
Learn real editor.
:set fileformat=dos
:w
File now saved with CR-LF line endings. Next time you open the file,
Vim will automatically use this fileformat setting.
If you you are just simply using a shared folder between Linux and
Windows, or copying the files back and forth, consider just keeping the
files in Windows format. If Octave and Gnuplot on Linux don't mind
the CR's, you're just fine. Edit in a decent editor and you won't
see the line endings.
Regarding conversion, the manpage for "unix2dos" and "dos2unix".
Another thing: you should consider putting your files into a
cross-platform version control system like Git. A version control system
can create a working copy of text files in the local operating system
format.
You can make a change on Windows to your Octave or Awk code,
commit the change, then push it out to your Linux-side repository
where the update is seen in Unix format.
No software developer worth their salt performs conversions on
their maintained source code between Unix and Windows. Version
control takes care of it.
I wouldn't develop anything other than throwaway code without version
control.
Thanks Much!!!
be back when I give it a try
signed up for github, when I download a text file it still doesn't work
in notepad, but it works in wordpad

guess it is a notepad problem
--
dale | http://www.dalekelly.org
Karl Ratzsch
2017-02-20 08:03:41 UTC
Permalink
Post by dale
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows
any ideas? probably could do an awk file on each, that would save some time
want to do them in a batch all at once, guess I could do a bash script
of awk conversions
Just don't use the horrible built-in "notepad.exe" editor on windows,
but one of the much better configurable alternatives.
Kenny McCormack
2017-02-20 08:29:12 UTC
Permalink
Post by Karl Ratzsch
Post by dale
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows
any ideas? probably could do an awk file on each, that would save some time
want to do them in a batch all at once, guess I could do a bash script
of awk conversions
Just don't use the horrible built-in "notepad.exe" editor on windows,
but one of the much better configurable alternatives.
This is good advice. For the most part, there's no real problem with just
leaving the files as they are (i.e., in Unix/Linux format). Most Windows
programs will work OK. It is just that the default editor - the one people
intuitively recommend for newbies, even though they'd never actually use it
themselves - is brain dead about this.

The simplest alternative is "Wordpad", which is installed by default in
Windows (no special install or configuration needed) and has no problem
displaying files w/o CRs.

But, yeah, I get caught by this every once in a while - bringing up a Unix
file in Notepad and going Arrrrghhhh!
--
First of all, I do not appreciate your playing stupid here at all.

- Thomas 'PointedEars' Lahn -
dale
2017-02-20 17:02:53 UTC
Permalink
Post by Kenny McCormack
Post by Karl Ratzsch
Post by dale
I have a bunch of octave, gnuplot and awk files that I made in gedit on
linux, they only have a linefeed at the end of a line, I would like to
add a carriage return after each linefeed so I can see them on windows
any ideas? probably could do an awk file on each, that would save some time
want to do them in a batch all at once, guess I could do a bash script
of awk conversions
Just don't use the horrible built-in "notepad.exe" editor on windows,
but one of the much better configurable alternatives.
This is good advice. For the most part, there's no real problem with just
leaving the files as they are (i.e., in Unix/Linux format). Most Windows
programs will work OK. It is just that the default editor - the one people
intuitively recommend for newbies, even though they'd never actually use it
themselves - is brain dead about this.
The simplest alternative is "Wordpad", which is installed by default in
Windows (no special install or configuration needed) and has no problem
displaying files w/o CRs.
But, yeah, I get caught by this every once in a while - bringing up a Unix
file in Notepad and going Arrrrghhhh!
for some reason they need the carriage returns in a <div> code block in
HTML on Edge or Internet Explorer, I don't currently have an example to
show, but will be back, might be a CSS configuration for <div>
--
dale | http://www.dalekelly.org
Loading...