Users browsing this thread: 1 Guest(s)
evbo
Members
I don't know if this is weird or not, but I usually forget about which and do the following:

Code:
$ find / -name "which"
/bin/which

And for fun, here's an example of how to not optimize a search:

Code:
#!/usr/bin/env python3

import os
import re
import sys

def find_file(root, path):
    regex = re.compile(r"^" + re.escape(path) + r"$")
    for root, dirs, files in os.walk(root):
        for file in files:
            if regex.search(file):
                print(os.path.join(root,file))

find_file('/', str(sys.argv[1]))


Messages In This Thread
Where is what - by venam - 05-06-2017, 11:19 AM
RE: Where is what - by evbo - 05-06-2017, 12:20 PM
RE: Where is what - by xero - 05-06-2017, 12:58 PM
RE: Where is what - by alxndr - 05-06-2017, 03:13 PM
RE: Where is what - by yossarian - 05-06-2017, 10:02 PM
RE: Where is what - by venam - 06-06-2017, 01:13 PM
RE: Where is what - by jkl - 06-06-2017, 01:17 PM
RE: Where is what - by venam - 06-06-2017, 01:26 PM
RE: Where is what - by venam - 23-11-2021, 01:45 PM
RE: Where is what - by neeasade - 29-11-2021, 02:03 PM
RE: Where is what - by z3bra - 29-11-2021, 07:50 PM
RE: Where is what - by neeasade - 30-11-2021, 02:26 AM