Monday, December 24, 2018

Finding files after excluding some directories

Normally, to find a file recursively under a directory, we do something like

find path/to/directory -name "*filename*"

To exclude finding in some sub-directories under directory, we can do

find path/to/directory -name "*filename*" -not -path "*subdir1*" -not -path "*subdir2*"

[Courtesy: this]

Tuesday, December 4, 2018

Python regex to match decimal numbers

Here is a Python regex to match regular decimal numbers (without the e or exponent part):
r'([+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+))'