Solved

echo commands for tab and return

Posted on 2004-08-18
6
2,206 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
6 Comments
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
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
Comment Utility
0
 

Author Comment

by:jwcorbett
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 23

Expert Comment

by:Mysidia
Comment Utility
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 50 total points
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now