Menu
Text Links
Search
Calendar
Solution: Converting line breaks
rechosen | 06 February, 2007 20:19
To convert a text file with Windows-like line breaks to a one with Linux-like line breaks:
[rechosen@localhost linebreaks]$ dos2unix <textfile>
And the other way around (Linux-like line breaks to Windows-like line breaks):
[rechosen@localhost linebreaks]$ unix2dos <textfile>
You might wonder why you should ever use this. Well, for example, when opening a file with Linux-like line breaks in Window's Notepad, the file will appear as one long line and every linebreak will be replaced by two blocks. This is quite annoying. And, the other way around, if you're trying to run a bash script that contains Windows-like line breaks, bash will fail miserably at interpreting it.
By the way, if you don't have Linux near to convert a text file with Linux-like line breaks and you need to edit it on Windows, you can also use Wordpad (located at Start => Programs => Accessories => Wordpad) to open the file. Wordpad does support Linux-like line breaks.
Comments
Add comment
Recently...
- Solution: Converting flac to mp3 advanced (supports drag 'n drop)
- Tutorial: Conditions in bash scripting (if statements)
- Linux Tutorial Blog is no longer frozen!
- Solution: Getting a Gravis GamePad Pro to work on Linux
- Linuxtutorialblog.com is now officially frozen!
- Solution: Preventing damage after a system lockup
- Solution: Creating an mpeg with mencoder that plays on Windows Media Player
- Cropping multiple images the same way (short tutorial)
- Solution: Converting flac to mp3
- Tutorial: Disabling unused daemons to speed up your boot sequence
Trackbacks (0)