diff --git a/1ano/2semestre/labi/tema02/cmd_comand.py b/1ano/2semestre/labi/tema02/cmd_comand.py new file mode 100644 index 0000000..8981dcd --- /dev/null +++ b/1ano/2semestre/labi/tema02/cmd_comand.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +if len(sys.argv) < 3: + print("Usage: python Ex3.py ") + sys.exit(1) + +directory_path = sys.argv[1] +ignore_term = sys.argv[2] + +try: + output = subprocess.check_output(["ls", "-la", directory_path], universal_newlines=True) + lines = output.split("\n") + filtered_lines = [line for line in lines if ignore_term not in line] + print("\n".join(filtered_lines)) +except subprocess.CalledProcessError: + print("Error: could not list directory.") + sys.exit(1)