1 / 8

String Processing

String Processing. Word Counting. Linux stores text in files using an encoding scheme. The most popular is ASCII encoding. Using ‘ wc ’ command, we can count the number of lines, characters and words in a file.

Download Presentation

String Processing

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. String Processing

  2. Word Counting Linux stores text in files using an encoding scheme. The most popular is ASCII encoding. Using ‘wc’ command, we can count the number of lines, characters and words in a file. The ‘head’ and ‘tail’ commands allows us to examine the first or last few lines of a text file.

  3. Text searching • There are a few tools for searching text. They are:- • fgrep Does a fast search for simple patterns. • grep Pattern searches using ordinary regular expressions. • egrep Pattern searches using more powerful extended regular expressions. • Normally, we use ‘grep’ to search for text.

  4. Regular Expressions Regular expressions are a standard Unix syntax for specifying text patterns. Regular expressions are understood by many commands, including grep Within regular expressions, . and [] are used to match characters. Within regular expressions, +, *, and ?specify a number of consecutive occurrences. Within regular expressions, ^ and $ specify the beginning and end of a line. Within regular expressions, (, ), and | specify alternative groups. The regex(7) man page provides complete details.

  5. Regular Expression Classes

  6. Regular Expression is not File Globbing

  7. More tools To sort text in a file, use ‘sort’. To cut text in a file, use ‘cut’. To find out differences between two files, use ‘diff’. To spell-check a file use ‘aspell’. The fmt command can reformat text to differing widths. The split command can be used to split a single file into multiple files based on either a number of lines or a number of bytes.

More Related