I need to parse systemctl list-units --type=service --all --no-pager terminal output by using Python 3. I need to get every cell value of the output text.
Splitting whole output for every line:
text1 = subprocess.check_output("systemctl list-units --type=service --all --no-pager", shell=True).strip().decode()
text_split = text1.split("\n")
But every line have spaces and some line data also have spaces. Using .split(" ") will not work.
How can I do that?
OS: Debian-like Linux x64 (Kernel 4.19).
for i in text_split: i.split()which will provide a list of the data items within each line. Orx = [i.split() for i in text_split]giving x as a list of lists.' '.join(line.split()[3:])