Windows Batch Scripting/File Commands
3. File Commands
editThis chapter covers the following commands:
- COMP - Compares the contents of two files or sets of files.
- FC - Compares two files or sets of files, and displays the differences between them.
- FIND - Searches for a text string in a file or files.
- FINDSTR - Searches for strings in files.
- MORE - Displays output one screen at a time.
- PRINT - Prints a text file.
- SORT - Sorts input.
- TYPE - Displays the contents of a text file.
The TYPE Command
editThe TYPE command display the contents of a file. There are no options for the TYPE command.
C:\>TYPE README.TXT
This is a table of contents for "Editing Guide to Windows Commands"
File and Directory Management
File Commands
C:\>
The SORT Command
editThe SORT command will sort lines of text from a file.
Orange
Banana
Apple
Pear
Strawberry
Bluberry
Blackberry
--------
File: fruits.txt
C:\>sort fruits.txt
Apple
Banana
Blackberry
Bluberry
Orange
Pear
Strawberry
C:\>
The /R option will sort in reverse order.
C:\>sort /R fruits.txt
Strawberry
Pear
Orange
Bluberry
Blackberry
Banana
Apple
C:\>
The MORE Command
editThe MORE command will display output or contents of file a screenful at a time. It is especially useful when piping it with certain commands (such as DIR or TASKLIST) that produce very long output.
For example:
C:\>tasklist | more