Grep Log

Given a log file named input. You have to write a bash script which prints all the lines which contains mysql commands.


  • Assume that all the mysql commands start with mysql::.


Assume that the input has the following content:

mysql:: SELECT * FROM courses;
rails:: Course.all
mysql:: SELECT id FROM courses;
rails:: Course.pluck(:id)

Then your bash script should output the following:

mysql:: SELECT * FROM courses;
mysql:: SELECT id FROM courses;

Our engineers were able to write this much code, can you complete it for us?

cat input | grep

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Grep Log on Interview Code Editor
Sign Up
to access hints and editorial solutions for Grep Log


Click here to start solving coding interview questions