Google Production ML Lab Week 2 - Linux find and grep

1 view
Skip to first unread message

ritch...@abrs.com.hk

unread,
Mar 9, 2019, 11:13:52 PM3/9/19
to ma...@abrs.com.hk
In this lab, you were asked to 

Run the what_to_fix.sh script to see a list of items you need to add/modify to existing code to run your app:

./what_to_fix.sh


This file just run this command (which will find all TODO tasks remarked inside ALL files as listed within `......`:


grep TODO  `./ -type f`


What this will do is 


i) apply a grep command - grep will search through a file / list of files following and try to match the string TODO pattern against the CONTENT of the following string


ii) TODO is the pattern to be matched


iii) `..........` are special quote / end quote which refers to the CONTENT of whatever files inside the quote, instead of them as a list of strings, eg. `file1, file2......`, will treat those as file content, not the literal strings 'file1', 'file2'...


iv) `find ./ -type f`  - what this does is  find all files (-type f) from the current directory


Remarks:


i. Please also note whether you quote the string to search:  TODO, 'TODO', "TODO" will all work with grep

ii. You can (also save serving time) use:  

         grep TODO  `find ./ -name *.java`

         grep -r TODO PATH.... PATH refers to a path, eg. grep -r TODO ./  

iii. Back tick `: A backtick is not a quotation sign. It has a very special meaning. Everything you type between backticks is evaluated (executed) by the shell before the main command (like chown in your examples), and the output of that execution is used by that command, just as if you'd type that output at that place in the command line.(from Stackoverflow)










Reply all
Reply to author
Forward
0 new messages