1 / 19

Creating a new ASCII file

Creating a new ASCII file. Output usually goes to screen Output can be redirected to a file using the output redirection operator > (greater than symbol). Syntax to Create an ASCII File. Syntax: [command] > filename Example: dir > classfile.txt

ting
Download Presentation

Creating a new ASCII file

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creating a new ASCII file Output usually goes to screen Output can be redirected to a file using the output redirection operator >(greater than symbol)

  2. Syntax to Create an ASCII File Syntax: [command] > filename Example: dir > classfile.txt Note: If the filename already exists, the file will be OVERWRITTEN. Outputredirection symbol

  3. Appending to an Existing ASCII file Instead of overwriting a file, the new information can be added to the end of the existing file. Syntax: [command] >> filename Example: dir a: >> classfile.txt

  4. View an ASCII file The contents of a file can be viewed from the command prompt using the TYPE command. Syntax: TYPE filename Examples: TYPE mypoem.txt TYPE A:\Abc\mypoem.txt TYPE A:\Abc\mypoem.txt > PRN TYPE A:\mypoem.txt > A:\poemcopy.txt

  5. PRACTICE-TYPE Type in the following: • A:<enter> • DIR • DIR > classfile.txt • TYPE classfile.txt • DIR r* • DIR r* >> classfile.txt • TYPE classfile.txt (in a minute we will learn how to prevent the display from scrolling off the page)

  6. Using Redirect to Print Output can be redirected to a printer Syntax: [command] > printer port Examples: dir a: > PRN dir a: > LPT1

  7. PIPING and FILTERS The PIPE operator redirects the output of one DOS command to another command. It looks like this: | A FILTER is a DOS command that can modify the output of another DOS command. They are: • MORE • SORT • FIND

  8. Input and the MORE filter Input does not have to come from the keyboard Input can come from a file instead The MORE filter can take this input and alter the output The filter MORE displays a text file a page at a time on the computer screen Syntax: [command] | MORE Example: TYPE A:\programmer.txt | MORE

  9. Redirecting Input Using an ASCII Text File Windows XP lets you use MORE in another way Syntax: MORE < filename Example: MORE < SomeFile.txt

  10. Yet Another Way to Use MORE In Windows XP, MORE can be used the same way as TYPE Syntax: MORE filename Example: MORE A:\resume1.txt

  11. Recap of the MORE filter In Windows XP, you can get the same results by typing in each of the following: Type classfile.txt | More More < classfile.txt More classfile.txt

  12. Practice MORE Type in the following: • TYPE classfile.txt • TYPE classfile.txt | MORE • MORE < classfile.txt • MORE classfile.txt

  13. Sorting ASCII Text Files The content of an ASCII file can be sorted before it is displayed. The SORT filter accepts the input and sorts it before it is displayed. Syntax: SORT < filename Example: SORT < classfile.txt

  14. SORT syntax without redirect The SORT can be used without redirecting input. Syntax: SORT filename Example: SORT classfile.txt

  15. Reversing the Sort Order The SORT order can be reversed. Syntax: SORT /R < filename orSORT /R filename Examples: SORT /R < classfile.txt orSORT /R classfile.txt

  16. PRACTICE-SORT Type in the following: • SORT classfile.txt • SORT /R classfile.txt

  17. Searching the Contents of an ASCII File The FIND filter allows you to find information in a file SYNTAX: FIND “string” filename EXAMPLE: FIND “04” classfile.txt

  18. FIND and IGNORE CASE switch To have the command “ignore case” add the ignore switch SYNTAX: FIND /I “string” filename EXAMPLE: FIND /I “DOG” classfile.txt

  19. PRACTICE-SORT Type in the following: • FIND “04” classfile.txt • FIND “file” classfile.txt • FIND “file” /i classfile.txt • FIND “an” classfile.txt • FIND “an” classfile.txt /i

More Related