Solved

echo commands for tab and return

Posted on 2004-08-18
6
2,221 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

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

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This is about my first experience with programming Arduino.
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 …

733 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