In this command:
FOR /F %%A IN ('TYPE "%InFile%"^|find /v /c ""')DO SET "Till=%%A"
what does the ^
mean?
The @ symbol tells the command processor to be less verbose; to only show the output of the command without showing it being executed or any prompts associated with the execution. When used it is prepended to the beginning of the command, it is not necessary to leave a space between the "@" and the command.
Represents a replaceable parameter. Use a single percent sign ( % ) to carry out the for command at the command prompt. Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> )
When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.
The ampersand lets you construct, on one command line, compound-command statements that can run multiple commands.
The ^ symbol (also called caret or circumflex) is an escape character in Batch script. When it is used, the next character is interpreted as an ordinary character.
In your script, the output of the TYPE command to be written as the input to the FIND command.
If you don't use the escape character ^ before the |
, then the regular meaning of |
is a pipe character.
The Documentation says:
To display a pipe (|) or redirection character (< or >) when you are using echo, use a caret character immediately before the pipe or redirection character (for example, ^>, ^<, or ^| ). If you need to use the caret character (^), type two (^^).
The caret '^' character serves two purposes in Windows batch files:
1. line continuations:
~~~
@echo off dir ^ /ad ^ c:\temp
~~~~
results in dir /ad c:\temp, which lists only the directories in C:\temp.
2. Escaping reserved shell characters & | ( < > ^.
Use a preceding caret to escape and print the character:
echo this pipe will print ^| but this one won't | echo and this will print one caret ^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With