How do I make sense of a batch file?

2019-05-15 02:43发布

问题:

I have no prior experience working with batch files or shell scripting in general. I need to understand the operations being carried out by a batch file used in a related project. Any resource that gives exhaustive list of batch file commands and what each one does?

回答1:

Once you get acquainted with the general .BAT file information, using some of the pointers to useful information that other users have posted in the other answers, you might try some of the following strategies that help you understand and analyze the BAT files used int your projects:

  1. add an ECHO command in front of all command invocations

  2. read HELP command for each command line in the BAT file

  3. execute at the command prompt each command line in the BAT file

  4. remove the @echo off at the top of the .BAT file, and see how the BAT progresses

  5. add some PAUSEs to keep viewing some commands on screen before they disappear.



回答2:

There are some useful answers here in this Stack Overflow question: Best free resource for learning advanced batch-file usage?

As well there are quite a few resources available through google search for Batch file resources, as well as the Wikipedia entry http://en.wikipedia.org/wiki/Batch_files

That should get you started at least.



回答3:

A little search on google should give a lot of tutorials and websites with information on writing them for both Windows and Linux.

Maybe you should start from the beginning though.

http://ss64.com/nt/

http://academic.evergreen.edu/projects/biophysics/technotes/program/batch.htm

http://www.robvanderwoude.com/batchcommands.php

http://en.wikipedia.org/wiki/List_of_MS-DOS_commands

They're just a few examples i found with a little google search. You should search it and find something thats better for you.

Hope this helps.