16 January 2014

Pipe (|) symbol, Blank line and Comment in batch programming

Hi Friends,

Lets see how can you print the pipe line ( | ) symbol in batch file.  If you directly use the | symbol then batch file will throw an error.  To display the pipeline symbol in batch file, you have to use the "^" symbol just before the pipeline symbol.

As we know we use "echo hello" to print the hello then you might think to print line we can use the "echo" only. Am I right? but to display the blank line, we have to use the dot( . ) just after the echo word "echo." remember there should not be any space between echo and dot(.)

To mark the line as comment we have to use the double colon ( :: )

 Check the below example -

@echo off
echo.
echo above line is blank
::echo This line is comment as the line starts with Double colon (::)
echo +--------------------------------+
echo ^|                          ^|
echo ^|        Hello World..!!      ^|
echo ^|                          ^|
echo +--------------------------------+
pause

when you will try to run the above batch code, you will get the below output.


Happy Sharing.. :)

No comments:

Post a Comment