?
Solved

echo commands for tab and return

Posted on 2004-08-18
6
Medium Priority
?
2,231 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

801 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