当前位置:网站首页>First knowledge of batch processing
First knowledge of batch processing
2022-07-04 04:35:00 【Pineapple bun with butter】
The batch (Batch), Also known as batch scripts . seeing the name of a thing one thinks of its function , Batch processing is batch processing of an object , It is generally considered as a simplified scripting language , It is applied to DOS and Windows In the system . The extension of the batch is bat. There are two common types of batch processing :DOS Batch processing and PS The batch . The following and subsequent introductions are mainly based on DOS Batch based .
The default storage format of batch files is ANSI, That is to use Windows System default encoding format . But we cannot directly create batch files , It is usually created by creating a text file and then changing the extension , Therefore, you need to manually change the encoding format of the file to ANSI Format , In this way, we can prevent Chinese from being garbled .
Interpreter
- Batch processing is case insensitive .
- By default, the batch interpreter reads a line of code , Then explain one line execution
- If the batch interpreter reads parentheses "(“, Think you know the next corresponding ”)", For the end . This method allows the batch interpreter to interpret and execute multiple instructions at one time ( stay if Especially in the sentence )
- CTRL+C You can exit the currently executing batch .
grammar
echo
echo Instructions are the simplest and most common instructions in batch processing . It is equivalent to printing in other languages , Such as Python Of "print".echo You can output the information behind him on the terminal . Pay attention to the output information and echo There needs to be a space between .
echo Hello,World!
Close back display
When we create a batch script and write it, save and run the above instructions , Will find , Every command we write will be displayed on the terminal , Once the script is complex, it will look very ugly , Can we make it not show what commands we wrote ? The answer, of course, is yes . We just need to add a @ Can be realized .
@echo Hello,World!
The problem is coming again , If there are more orders , Isn't it necessary to add one for each @, Is there a more convenient way ? Of course. !
echo off Indicates that echo function is turned off , You can place this command at the top of the script , thus , The echo of the commands written below will be turned off
@echo off
echo Hello,World!
echo Hello,batch!
When echo is turned on @echo on
Output blank lines ( Line break )
In batch ",“、”.“、”:" Wait can follow closely echo Later, it plays the role of outputting blank lines . Note that there must be no spaces , Otherwise it will be output to the screen as information . It can also be used " / ] + \ These symbols replace .
Answer the questions in the order
You can use the pipe command , Use the previous results as input for the following . for example :
@echo off
rd /s c:\abc
pause
In the above script , After execution , Will be displayed :c:\abc, Are you sure (Y/N)?
Because here abc Is a folder that is not empty , So use rd Command to delete , Will ask you Y or N, At this time, you usually need to enter manually . We can modify the script and let the system automatically input Y Confirm :
@echo off
echo Y|rd /s c:\abc
pause
Create documents or add document contents
@echo off
echo 123>myfile.txt
pause
The above command can create a file named myfile.txt The file of , The content of the document is 123, To continue adding content, you can use :
@echo off
echo 456>>myfile.txt
If you want to create an empty file , Then you can use the command of outputting blank lines :
@echo off
echo. >myfile.txt
边栏推荐
- RHCSA 03 - 文件的基础权限
- Rhcsa 04 - process management
- 领导:谁再用redis过期监听实现关闭订单,立马滚蛋!
- Redis:有序集合zset类型数据操作命令
- 网络 - VXLAN
- Redis: operation command for collecting set type data
- Statistical genetics: Chapter 3, population genetics
- [microservices openfeign] two degradation methods of feign | fallback | fallbackfactory
- 浅谈一篇优质的小红书文案需要具备什么
- Wechat official account infinite callback authorization system source code
猜你喜欢

架构实战营 - 第 6 期 模块九之毕业设计

多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者

Flink learning 8: data consistency

GUI 应用:socket 网络聊天室

十字路口通行优先权,十字路口通行规则图解

微信脑力比拼答题小程序_支持流量主带最新题库文件

【微信小程序】好看的轮播图组件

Many founders of technology companies provided enterpriser first with a round C financing of up to US $158million to help it invest in the next generation of global innovators

How to view installed r packages in R language

Keysight n9320b RF spectrum analyzer solves tire pressure monitoring scheme
随机推荐
Intersection traffic priority, illustration of intersection traffic rules
Leetcode skimming: binary tree 07 (maximum depth of binary tree)
Rhcsa 08 - automount configuration
多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者
【微信小程序】好看的轮播图组件
ROS2中CMake编译选项的设置
B. All Distinct
Distributed cap theory
网络 - VXLAN
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Leetcode brush question: binary tree 06 (symmetric binary tree)
Touch your hand and bring you a commonjs specification
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
FT2000+下LPC中断绑核使用说明
Flink learning 6: programming model
Touch and take you to implement an EventEmitter
C语言单向链表练习
Statistical genetics: Chapter 3, population genetics
One click compilation and deployment of MySQL