Skip to content

Instantly share code, notes, and snippets.

@omamkaz
Created April 29, 2022 21:56
Show Gist options
  • Save omamkaz/266beeadb49c5968a40c07ead8755036 to your computer and use it in GitHub Desktop.
Save omamkaz/266beeadb49c5968a40c07ead8755036 to your computer and use it in GitHub Desktop.
print linux env paths
#!/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