Questions tagged [newlines]
145 questions
83
votes
10 answers
How do I convert a bash array variable to a string delimited with newlines?
I want to write out a bash array variable to a file, with each element on a new line. I could do this with a for loop, but is there another (cleaner) way to join the elements with \n?
ACyclic
- 1,003
46
votes
14 answers
Convert Unix line endings to Windows
I recently moved back to Windows from Linux. I have some files with CRLFs, some with LFs and some that are mixed. Is there a utility that will help me find all my Unix-touched files and convert them to proper CRLF terminated files?
The utility must…
Matthew Scouten
- 1,961
45
votes
3 answers
Vim: show line feeds & carriage-return
How can I display line feeds and/or carriage-return characters in vi/vim?
I know that set list shows all the whitespace characters (?), it also replaces tabs \t etc (but that's not what I want). Basically I just want to display certain characters…
watain
- 731
43
votes
7 answers
How can I insert a new line in a cmd.exe command?
I'm trying to execute a command on cmd.exe, with a line break or new line as part of the command, like below:
command -option:text
whatever
But every new line executes the command, instead of continuing the command on the next line.
So how can I…
rudimenter
- 531
39
votes
1 answer
Did Mac OS Lion switch to using line feeds (LF '\n') for line breaks instead of carriage returns (CR '\r')?
I switched to Lion a while back and just noticed that when I save a text file in TextEdit, it uses LF for line breaks. I looked around everywhere I could think of on my Lion computer and could not find any evidence of files using CR for line breaks…
Matt
- 857
32
votes
3 answers
How are \n and \r handled differently on Linux and Windows?
I think \n moves the needle down, and \r moves the needle to the beginning of a line (left align)? I'm not sure, though. So, if I'm wrong please correct me....
Anyway, I was told that Windows and Linux handle newlines and carriage returns…
千里ちゃん
- 431
- 1
- 4
- 5
30
votes
5 answers
Replace newline character with another in Word 2007
Using Microsoft Word 2007, is it possible to replace the newline character (\n) with some other character?
What about vice versa? (That is replace a character with the newline character).
amir joudaki
28
votes
3 answers
How do I interactively type \r\n-terminated query in netcat?
$ nc example.com 80
GET / HTTP/1.1
Host: example.com
HTTP/1.1 200 OK
...
It works, line separator is just 0A here instead of required 0D0A.
How do I type a 0D0A-separated query in netcat?
It is easy to do one-time thing with printf manually…
Vi.
- 17,755
28
votes
5 answers
Why is Vim adding a newline? Is this a convention?
If I open Vim and type itest:wq then I get a file that has no newlines in Vim but does seem to have a newline in the code:
$ vim -u NONE test.txt
$ cat test.txt | hd
00000000 74 65 73 74 0a |test.|
00000005
If I open Vim…
dotancohen
- 11,720
28
votes
3 answers
How can I use newline with the Find-And-Replace in Visual Studio?
I've become rather fond of the "Find-And-Replace" function in Visual Studio. The function lets me replace phrases, words, symbols, or whatever you can type into the textbox on the screen.
How can I make it replace a character with a newline?
Vivian River
- 545
26
votes
6 answers
Copy multiple lines from Windows Command prompt without forced newlines
Is it possible to copy multiple lines from the Windows Command Prompt without it inserting a new line where each line reaches the end of the terminal?
For example, if I have the following line in the…
Adam Millerchip
- 1,656
24
votes
9 answers
Is there a Bash command to convert \r\n to \n?
Is there a Bash command to convert \r\n to \n?
When I upload my scripts from Windows to Linux, I need a utility like this to make things work.
user25321
- 381
23
votes
2 answers
What is the magic separator between filenames in ls output?
The output of ls (with no arguments) appears to separate filenames with linebreaks.
Evidence:
ls | grep foo works as expected, with grep treating each filename as a separate line of input.
ls > files.txt; vim files.txt --> in Vim, each file is on a…
Chris B
- 333
19
votes
3 answers
How to print new line character with echo?
I dump a string with hexdump like this 2031 3334 2e30 0a32 2032 3331 302e 000a. It is clear that 0x0a is new line character, however, when I try to echo this string out, I always got 1 430.2 2 13.0 -- the new line is replaced with a space, even I…
Summer_More_More_Tea
- 1,053
18
votes
6 answers
Wrong newline character over serial port (CR instead of LF)
I'm trying to talk to a device using a usb-to-serial converter on linux. Drivers are working, the device exists at /dev/ttyUSB0.
There is a strange problem (checked with a null-modem cable to another computer): Whatever program I use to connect to…
ChristophK
- 330
- 1
- 2
- 11