Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

echo commands for tab and return

Posted on 2004-08-18
6
Medium Priority
?
2,237 Views
Last Modified: 2013-11-18
Hello,
When writing a batch file, there's a few instances when I'd like to use echo and have it tab over, is there an ASCII, or character equivalent to tab within an echo statement (without using whitespace)?  Also, along those same lines, is there a carriage return?  This is on XP, on UNIX you'd just use /t, but I'm not sure how to work this with Uncle Bill.
Thanks for your help!
-J
0
Comment
Question by:jwcorbett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 11836342
for the carriage return...

echo.

e.g.:
echo. Hello World

outputs Hello World followed by carriage return

echo.

outputs a carriage return

as for the tabbing... not sure (can't you use spaces)?
0
 
LVL 23

Expert Comment

by:Mysidia
ID: 11836343
0
 

Author Comment

by:jwcorbett
ID: 11836533
Is there a way to use the ASCII sequence in a script? Perhaps setting the sequence in a variable and calling it?
I'm dynamically creating a file and it needs to have both a carriage return and tabs (it's using sed).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Mysidia
ID: 11836791
In a sed expression, tab is \t

You should be able to just embed a literal tab in the file..

i.e. from the command prompt's edit.com  use the "TAB" key, and it should embed a tab

you could set a variable to it for cleanness, but in Windows BAT/CMD files you won't find a notion of
special escape sequences like you have in UNIX.
0
 
LVL 11

Accepted Solution

by:
griessh earned 150 total points
ID: 11844245
Hi jwcorbett,

if you create a varaiable tab
set tab=<tab>
where <tab> is created with the TAB key, you can use that variable like
echo abc%tab%def

the CR will be more complicated, but if you 'echo' your strings out, each echo will end with a CR/LF

======
Werner
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 38137954
For CR, you can use a tricky string substitution to achieve this.  For example, let's say you want to use \n to represent your new line characters:

  set TEST=This is\na new\nline test.
  echo %TEST:\n=&echo.%
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question