Solved

echo commands for tab and return

Posted on 2004-08-18
6
2,212 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 50 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove header from multiple csv files using batch script 11 80
Plain Text Editor for iPad 6 75
Auto-indent certain lines in Notepad++ 10 73
Help Required 2 29
This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

813 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

12 Experts available now in Live!

Get 1:1 Help Now