Practical uses of Grep
1. Suppose you have multiple files in the system with the same first name and last name but the middle name is different (example xxx-4.deb, xxx5.deb). You have to find out the specific file (xxx6.deb). How will you perform this task? Ans: Grep is a powerful file pattern searcher tool, which helped in searching the specific file. Grep stand for Global regular expression print. Command : dpkg -l | grep -i xxx6.deb dpkg -l list out all the files and grep -i filter the output. Benefits : Grep saved the user time while searching the file. Pictorial Representation: As you can see in above diagram, grep find out the file which you are looking for. 2. Suppose you are working as an Apache administrator in XYZaa company. There is some issue occur in the Apache server. Senior Engineer asked you to send the content of configuration file without commented lines. How will you perform this task? Ans : grep -v '#' filename Above command will pr...