•can be used to look in files in the current directory, eg,grep Expn *.txtlists 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 Expnlists 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
•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
Regular expressionsA regular expressions (regex or regexp for short) is a string (pattern) consisting of specialcharacters (meta-symbols) and regularcharacters. Regular chars are all those that are not special chars.
•dir| grep “^DIR”all the file names starting with DIR (^ means that this must be the start of the line)•grep “g.*g” *.txtall 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” *.txtall 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
I inherited most of the materials of this unit from A/Prof PyaraDhillon (who was the coordinator for ICT306).Acknowledgement
•Basics of SW Architecture/Design•SDLC•Predictive vs Adaptive design •Pipe and Filter methodSummary