How to assign the effect of command execution to a variable like a shell under a bat batch

Source: Internet
Author: User
Tags svn uuid

How do you implement a shell-like command to assign a value to a variable under bat?

At first, it was really hard for me. With the familiarity of bat batch knowledge deepened.

Learning to!!!

Give me a chestnut:

Svnlook UUID C:\Repository\test # What do you mean by this line of command? It's a command of the SVN server (because it's been doing SVN stuff lately).

# So the effect of this line of command is to return the UUID of the test repository

This is done under the shell:

Uuid= ' Svnlook uuid C:\Repository\test ' # here is · Oh.    This symbol is the one under the keyboard Esc button · (It's so small ........) )

==================================================

OK ~ ~ ~ See, the shell implementation is really very simple, bat under the can be achieved but a bit of trouble.

DOS under: for/f "delims="%t in (' Svnlook uuid C:\Repository\test ') do set uuid=%t

BAT file: for/f "delims="%%t in (' Svnlook uuid C:\Repository\test ') do set uuid=%%t

The difference above is that DOS executes as%t, BAT file execution is%%t.

It is also important to note that the single quotation marks are used in the bat because the single quotation mark is the meaning of the reference command.

The delims here is worth the meaning of the delimiter. What I'm writing here is "delims=". There is no delimiter, so the row is split,

This allows you to take the result of the first line.

Learn this and write bat again. The script is more beautiful and more concise. Can be 10 floors in a breath. Ha ha.

How to assign the effect of command execution to a variable like a shell under a bat batch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.