Created
April 29, 2022 21:56
-
-
Save omamkaz/266beeadb49c5968a40c07ead8755036 to your computer and use it in GitHub Desktop.
print linux env paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from os import getenv | |
_paths = getenv("PATH").split(":") | |
def print_type(title: str, _filter: tuple): | |
print(f"\n@{title.title()} dirs:") | |
for (index, fp) in enumerate(filter(lambda fp: fp.startswith(_filter), _paths), 1): | |
print(f"{index:3}- {fp}") | |
def main(): | |
print_type("root", ("/sbin", "/usr", "/bin", "/share", "/lib", "/opt")) | |
print_type("user", ("/home",)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment