赞
踩
Type命令对一般文本文件(.txt)进行处理,对其他类型文件就不好用了。
基本语法 type [drive] [path] [filename],本命令是用于打开txt文档,并在cmd窗口显示txt中的内容。
实例一
type helloworld.txt
以下是源代码:
@echo off
echo the below content from helloworld:
echo.
type helloworld.txt
echo.
echo.
pause
执行后:
the below content from helloworld:
Stray birds of summer come to my window to sing and fly away.
And yellow leaves of autumn, which have no songs, flutter and fall
there with a sign.
Press any key to continue . . .
实例二
通过type命令合并两个txt文档。提前新建两个txt文档,一个是pen.txt内容是 “I have a pen,”,再新建一个apple.txt内容是“I have an apple”,最后我们合并的文件名叫PPAP.txt。
以下是源代码:
@echo off
echo pen.txt below:
type pen.txt
echo.
echo.
echo apple.txt below:
type apple.txt
echo.
type pen.txt apple.txt > PPAP.txt
echo.
type PPAP.txt
echo.
echo.
pause
执行后:
pen.txt below: I have a pen, apple.txt below: I have an apple. pen.txt apple.txt I have a pen,I have an apple. Press any key to continue . . .
其实还有更多命名,推丸菌就不一 一运行了,仅把命令和介绍罗列如下:
type 文件名 | more ::“type 文件名”是将内容一次性打印出来,加上“more”命令是分页打印,并且按任意键可以获得后续内容,很适合内容多的文件
type 文件名 | findstr [/i] 内容 ::该命令类似于查找命令,即查找“内容”并打印出来,其他的无关内容不会打印出来,/i表示是否区分大小写
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。