Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Using line continuation in Windows XP Command environment

Aug 23, 2012 12:54AM PDT

I'm trying to understand how (if?) I can continue long lines in the Windows XP command environment. e.g. in Unix I can do this:

echo "foo" \
> "bar" \
> "baz"
foo bar baz

I tried this in Windows XP:

C:\>echo "foo" ^
More? "bar" ^
"foo" "bar" ^

C:\>

(I tried to use the caret as a continuation character). but, as you can see (and try, if you like), the second caret is taken as part of the text to be echoed and not as a continuation.

Can I achieve the same effect on XP as I can on Unix? If so, how would I do that?

Discussion is locked

- Collapse -
Answer
From memory.
Aug 23, 2012 6:24AM PDT

I could be faulty but from memory you can install "bash" for Windows and get this working.
Bob

- Collapse -
but it needs to work in an out-of-the box system
Aug 23, 2012 6:46AM PDT

Sure, I can install bash. Even better, I can do it very simply in PowerShell. TMTOWTDI for sure.

In my case, I need it to work on a standard installation without any 3rd-party apps installed.

- Collapse -
Can't use bash or Powershell
Aug 23, 2012 6:49AM PDT

Actually, it needs to work in the standard command environment. I can't even use PowerShell in this case

- Collapse -
(NT) Then no.
Aug 23, 2012 10:12AM PDT
- Collapse -
Answer
Try this ...
Aug 23, 2012 4:50PM PDT

You could make use of command redirection operators and this link should help you out with them:
http://technet.microsoft.com/en-us/library/bb490982.aspx

For example, if you type what is bolded and italicized here you will get back what is bolded as shown here.
c:\>echo foo 0>&1 bar 0>&1 baz 0>&1 (what you type)
foo bar baz (what you get back in STDOUT)

Note the output to the command prompt window - STDOUT - has an extra space between each element because spaces in the command are important. This example shows how to rectify that extra space problem.

c:\>echo foo 0>&1bar 0>&1baz 0>&1 (what you type)
foo bar baz (what you get back in STDOUT)

If I misunderstood what you are after and what you want is simply to exceed the 256 character limit try copy con as follows:

copy con (press enter key)
type some text here until you get tired of typing
then press the Ctrl + z keys

- Collapse -
I really want to continue parameters onto new lines
Aug 23, 2012 11:06PM PDT

What I really want to do, is exactly like what I can do in bash, but in the Windows command shell.

e.g. in bash I can do this:

echo "The quality of mercy "\
> "is not strain'd. "\
> "It droppeth as the gentle rain"\
> "from heaven."
The quality of mercy is not strain'd. It droppeth as the gentle rain from heaven.
jerryb1@ubuntu:~$

Can I do the same in the Windows shell? That is, can I start the echo command with one phrase, then continue it to the next line and the next and the next?

Here's another example. Say I want to copy several files into one file. Copy let's me do this:

copy foo+bar baz

Now, consider a case where the filenames are long. For readability, I'd like to do this:

copy <continuation character>
"this is the first file with a long name" + <continuation character>
"this is the second file with an even longer name" <continuation character>
"this is the concatenation of the first and second files"

Can this be done in the standard Windows shell? If so, what would I type for the <continuation character>?

- Collapse -
Answer
Using "new line"
Aug 23, 2012 9:09PM PDT

I wish to receptive a good DOS eyeport (during WinXP) after which you can go only one longer
DOS command word with a group submit.

Any group submit formulated with any longer command word appearance messay as well as being really hard
in my situation that will modification instantly. How one can switch any style for this longer
command word during the group submit to build it all even more legible?

In a perfect world I would really prefer of having different parts of it all (command word identity,
sart submit identity, last part submit identity, or anything else) regarding distinguish ranges. There has to be a good
strategy Allow me to insert those sections every one at a different path however , provide the completely
idea recognised as the simple command word?