can be used to look in files in the current directory eg grep Expn txt lists

Can be used to look in files in the current directory

This preview shows page 54 - 61 out of 61 pages.

can be used to look in files in the current directory, eg, grep Expn *.txt lists all the lines in any ‘.txt’ file in the directory which contains the string (or pattern) “ Expn ”. can be used to look in any input file, eg, dir | grep Expn lists each of the files in the current directory whose name contains Expn ”. the argument “ Expn ” to grep can be a simple string or a pattern described in a simple language. The patterns are called regular expressions . GREP in MS-DOS
Image of page 54
details of regular expressions can be found, e.g., Note that in DOS it is best to quote the expression inside double quotes to prevent special characters being interpreted by DOS. GREP in MS-DOS
Image of page 55
Regular expressions A regular expressions (regex or regexp for short) is a string (pattern) consisting of special characters (meta-symbols) and regular characters. Regular chars are all those that are not special chars.
Image of page 56
dir | grep “^DIR” all the file names starting with DIR (^ means that this must be the start of the line) grep “g.*g” *.txt all lines in any ‘.txt’ file which contain two letter g’s. (the . matches any character and the .* matches any sequence of any characters) grep “g[a - z]*g” *.txt all lines in any ‘.txt’ file which contain two letter g’s separated only by lower case letters (the [a-z] matches any lower case) Regular expressions: examples
Image of page 57
I inherited most of the materials of this unit from A/Prof Pyara Dhillon (who was the coordinator for ICT306). Acknowledgement
Image of page 58
Summary
Image of page 59
Basics of SW Architecture/Design SDLC Predictive vs Adaptive design Pipe and Filter method Summary
Image of page 60
Image of page 61

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture