Reputation: 1982
When I run a batch file, the output contains the command prompt for each command executed. I want to collect the command executed, but I don't want the prompt (which is the directory). I can sed -e 's/^.:[^>]*>'
to remove the prompt but might remove some valid output too.
Is there a way to not echo the directory from which the command is running?
Upvotes: 0
Views: 138
Reputation: 4142
You can change the prompt (see prompt /?
) in your script. This example sets the prompt to a single space.
SETLOCAL
prompt $S
:: do stuff
I don't know how to change the prompt to nothing, but if you want the output to be readable, I'd probably change it to something short and unique, like >>>
:
SETLOCAL
prompt $G$G$G$S
For example, this script
@ECHO OFF
SETLOCAL
PROMPT $G$G$G$S
dir /b
time /t
date /t
produces this output:
>>> dir /b
bang.cmd
bang.txt
date1.cmd
list.txt
list_complete.txt
pmpt.cmd
q2.cmd
temp.zip
temp_orig.zip
timetest.cmd
z.cmd
>>> time /t
01:17 PM
>>> date /t
Fri 06/28/2013
Upvotes: 2
Reputation: 2930
You need to change the prompt. See http://www.computerhope.com/prompthl.htm. You can set it, for instance, to $_
(carriage return and linefeed): prompt $_
, or $H
(backspace): prompt $H
. I don't know if there's a way to set it to empty.
Upvotes: 1