Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question
In linux, issue command to find all lines containing string "username" in all python files in current directory and all subdirectories below it.
Answer

find . -name '*.py' | xargs grep 'username'

^^ note the user of find to locate all the python files, and how the glob pattern *.py is within single quotes

^^^ note the use of xargs (i.e. how xargs takes all the output from find, seperates it by whitespace/newline, and feeds it to the grep command, one by one, as command line args)

^^^^ note that output will have name of file, along with the line that has the 'username' regex pattern


Question
In linux, issue command to find all lines containing string "username" in all python files in current directory and all subdirectories below it.
Answer
?

Question
In linux, issue command to find all lines containing string "username" in all python files in current directory and all subdirectories below it.
Answer

find . -name '*.py' | xargs grep 'username'

^^ note the user of find to locate all the python files, and how the glob pattern *.py is within single quotes

^^^ note the use of xargs (i.e. how xargs takes all the output from find, seperates it by whitespace/newline, and feeds it to the grep command, one by one, as command line args)

^^^^ note that output will have name of file, along with the line that has the 'username' regex pattern

If you want to change selection, open document below and click on "Move attachment"

20. Advanced Shell Scripting
mand returns rather a lot of data. However, going through it carefully can be quite instructive.) Limiting a search to a certain file extension is just another common use of this pipe sequence. <span>find /usr/src/linux -follow -type f -name '*.[ch]' | xargs grep -iHn pcnet Note that new versions of grep also have a -r option to recursively search through directories. 20.7.6 Recursive search and replace Often you will want to perform a search-and-replace t

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.