areslp
areslp

Reputation: 473

echo -n not working under cygwin

I want to echo something to a file, for example:

aaaa
bbbb

man echo says:

-n     do not output the trailing newline

So I echo -n aaaa\r\nbbbb > somefile.txt

but the \r\n is output as text, not newline... The command above is ok under ubuntu12.04. I'm using win7 64bit, cygwin 1.7.16-1.

Upvotes: 0

Views: 1150

Answers (2)

Chris Seymour
Chris Seymour

Reputation: 85883

You need quotes and the -e option to enable interpretation of backslash escapes:

echo -en "aaaa\r\nbbbb" > somefile.txt

Tested in Cygwin, Does the job :)

Upvotes: 2

Christian
Christian

Reputation: 4104

Try this:

echo -n aaaa$'\r\n'bbbb > somefile.txt

That works under cygwin and ubuntu.

Edit:

or

echo -e 'aaaa\r\nbbbbb' > somefile.txt

Upvotes: 2

Related Questions