How do I create a multiline text file with Echo in Windows command prompt?
I'm using Windows 7 and I would like to quickly create a small text file with a few lines of text in the Command prompt.
I can create a single line text file with:
echo hello > myfile.txt
but how can I create a text file with multiple lines using this echo command? I have tried with the following, which doesn't work when I read the file with more
:
echo hellonsecond line > myfile.txt
Any suggestions? Or is there any other standard command that I can use for this instead of echo
?
windows command-line echo textfiles
add a comment |
I'm using Windows 7 and I would like to quickly create a small text file with a few lines of text in the Command prompt.
I can create a single line text file with:
echo hello > myfile.txt
but how can I create a text file with multiple lines using this echo command? I have tried with the following, which doesn't work when I read the file with more
:
echo hellonsecond line > myfile.txt
Any suggestions? Or is there any other standard command that I can use for this instead of echo
?
windows command-line echo textfiles
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10
add a comment |
I'm using Windows 7 and I would like to quickly create a small text file with a few lines of text in the Command prompt.
I can create a single line text file with:
echo hello > myfile.txt
but how can I create a text file with multiple lines using this echo command? I have tried with the following, which doesn't work when I read the file with more
:
echo hellonsecond line > myfile.txt
Any suggestions? Or is there any other standard command that I can use for this instead of echo
?
windows command-line echo textfiles
I'm using Windows 7 and I would like to quickly create a small text file with a few lines of text in the Command prompt.
I can create a single line text file with:
echo hello > myfile.txt
but how can I create a text file with multiple lines using this echo command? I have tried with the following, which doesn't work when I read the file with more
:
echo hellonsecond line > myfile.txt
Any suggestions? Or is there any other standard command that I can use for this instead of echo
?
windows command-line echo textfiles
windows command-line echo textfiles
asked Nov 3 '12 at 11:06
JonasJonas
9,6723994120
9,6723994120
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10
add a comment |
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10
add a comment |
3 Answers
3
active
oldest
votes
You could use the >> characters to append a second line to the file, e.g.
echo hello > myfile.txt
echo second line >> myfile.txt
add a comment |
There are three ways.
Append each line using
>>
:
C:UsersElias>echo foo > a.txt
C:UsersElias>echo bar >> a.txt
Use parentheses to echo multiple lines:
C:UsersElias>(echo foo
More? echo bar) > a.txt
Type caret (
^
) and hit ENTER twice after each line to continue adding lines:
C:UsersElias>echo foo^
More?
More? bar > a.txt
All the above produce the same file:
C:UsersElias>type a.txt
foo
bar
add a comment |
You can put a space between each line to write:
echo line1 line2 "line 3" > file.txt
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f498908%2fhow-do-i-create-a-multiline-text-file-with-echo-in-windows-command-prompt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use the >> characters to append a second line to the file, e.g.
echo hello > myfile.txt
echo second line >> myfile.txt
add a comment |
You could use the >> characters to append a second line to the file, e.g.
echo hello > myfile.txt
echo second line >> myfile.txt
add a comment |
You could use the >> characters to append a second line to the file, e.g.
echo hello > myfile.txt
echo second line >> myfile.txt
You could use the >> characters to append a second line to the file, e.g.
echo hello > myfile.txt
echo second line >> myfile.txt
edited Jun 19 '15 at 0:53
Bugalugs Nash
1115
1115
answered Nov 3 '12 at 11:09
Ian BakerIan Baker
16613
16613
add a comment |
add a comment |
There are three ways.
Append each line using
>>
:
C:UsersElias>echo foo > a.txt
C:UsersElias>echo bar >> a.txt
Use parentheses to echo multiple lines:
C:UsersElias>(echo foo
More? echo bar) > a.txt
Type caret (
^
) and hit ENTER twice after each line to continue adding lines:
C:UsersElias>echo foo^
More?
More? bar > a.txt
All the above produce the same file:
C:UsersElias>type a.txt
foo
bar
add a comment |
There are three ways.
Append each line using
>>
:
C:UsersElias>echo foo > a.txt
C:UsersElias>echo bar >> a.txt
Use parentheses to echo multiple lines:
C:UsersElias>(echo foo
More? echo bar) > a.txt
Type caret (
^
) and hit ENTER twice after each line to continue adding lines:
C:UsersElias>echo foo^
More?
More? bar > a.txt
All the above produce the same file:
C:UsersElias>type a.txt
foo
bar
add a comment |
There are three ways.
Append each line using
>>
:
C:UsersElias>echo foo > a.txt
C:UsersElias>echo bar >> a.txt
Use parentheses to echo multiple lines:
C:UsersElias>(echo foo
More? echo bar) > a.txt
Type caret (
^
) and hit ENTER twice after each line to continue adding lines:
C:UsersElias>echo foo^
More?
More? bar > a.txt
All the above produce the same file:
C:UsersElias>type a.txt
foo
bar
There are three ways.
Append each line using
>>
:
C:UsersElias>echo foo > a.txt
C:UsersElias>echo bar >> a.txt
Use parentheses to echo multiple lines:
C:UsersElias>(echo foo
More? echo bar) > a.txt
Type caret (
^
) and hit ENTER twice after each line to continue adding lines:
C:UsersElias>echo foo^
More?
More? bar > a.txt
All the above produce the same file:
C:UsersElias>type a.txt
foo
bar
edited Jun 19 '15 at 1:31
Bugalugs Nash
1115
1115
answered Nov 3 '12 at 11:26
efotinisefotinis
3,1741622
3,1741622
add a comment |
add a comment |
You can put a space between each line to write:
echo line1 line2 "line 3" > file.txt
add a comment |
You can put a space between each line to write:
echo line1 line2 "line 3" > file.txt
add a comment |
You can put a space between each line to write:
echo line1 line2 "line 3" > file.txt
You can put a space between each line to write:
echo line1 line2 "line 3" > file.txt
answered Jan 21 at 14:02
CarlCarl
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f498908%2fhow-do-i-create-a-multiline-text-file-with-echo-in-windows-command-prompt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/questions/132799/…
– akira
Nov 3 '12 at 11:10