In some of my python-scripts, I got glob.glob(parent_folder_path + glob_str)
.
These lines with the associated files shall be printed out in the console with a proper grep command, but so far I couldn't find out how.
The one which worked for finding all the glob.glob
- lines is the following:
grep --exclude-dir='.history' --exclude-dir='__pycache__' --exclude-dir='.wine' -Rinw /home/andylu/Desktop/Python/Scripts/ -e 'glob.glob'
Still it's not the preciseness I would like to achieve.
When using 'glob.glob(p*'
as the regex-string, only a line with glob.glob()
appears in the search result. I couldn't make sense out of this since (p*
gave me results with ()
.
Next, I tried 'glob.glob(p.*'
which indeed worked out and showed me all results with glob.glob(parent_folder_path + glob_str)
.
Even though I managed to find it out via trial and error, I'd like to understand the grep-syntax better.
Did the last regex-string work because, according to this cheat-sheet, .
stands for any character and *
for any number of repeated times?
p*.
means zero-or-more occurrences ofp
character followed by a single character; what pattern do you want to match? answer based on title of the question you only need(p\w+
.'glob.glob(p.*'
working, that's what I wanted to state here, but wrote initially'glob.glob(p*.'
. Thanks for the hint. Your suggestion of(p\w+
did not work though.