13

Finding a Particular Pattern In UNIX

view full story
linux-howto

http://www.unix.com – Hi, Suppose I have a file with many lines as follows. Now I want to find the following questions from the file through shell script or commands. Code: My name is XYZ. XYZ works for GHT and XYZ is part of PES. GHT is a good organization. XYZ knows swimming. XYZ is also very keen in reading. XYZ is a very hardworking guy. Now, (i) How many occurrences of XYZ are there? (ii) Print lines where XYZ occurrence is more than 1. (iii) Print lines which start with XYZ (iv) Print lines which end with XYZ (v) Print lines which doesn't have XYZ Thanks for the inp (HowTos)