Skip to content

Instantly share code, notes, and snippets.

@drew-holt
Last active March 30, 2018 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drew-holt/2fd64ecb3848dd1e798aa75dca5de914 to your computer and use it in GitHub Desktop.
Save drew-holt/2fd64ecb3848dd1e798aa75dca5de914 to your computer and use it in GitHub Desktop.
python stuff
drew@drew-8570w:~$ cat output.txt
Extension Packs: 1
Pack no. 0: Oracle VM VirtualBox Extension Pack
Version: 5.2.8
Revision: 121009
Edition:
Description: USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.
VRDE Module: VBoxVRDP
Usable: true
Why unusable:
drew@drew-8570w:~$ cat output.txt | python -c "import sys; a=dict(s.split(':') for s in sys.stdin); print a['Extension Packs'].strip();"
1
drew@drew-8570w:~$ cat output.txt | python -c "import sys; a=dict(s.split(':') for s in sys.stdin); print a.keys()"
['Usable', 'Description', 'VRDE Module', 'Pack no. 0', 'Extension Packs', 'Edition', 'Version', 'Why unusable', 'Revision']
drew@drew-8570w:~$ cat output.txt | python -c "import sys; a=dict(s.split(':') for s in sys.stdin); print a.values()"
[' true\n', ' USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.\n', ' VBoxVRDP\n', ' Oracle VM VirtualBox Extension Pack\n', ' 1\n', '\n', ' 5.2.8\n', ' \n', ' 121009\n']
cat some.json | python -c "import sys, json; print json.load(sys.stdin)['anArray'][0]['subArray'][0]['someValue']"
drew@drew-8570w:~$ cat output.txt | python -c "import sys; print dict(s.split(':') for s in sys.stdin)['Extension Packs'].strip()"
1
drew@drew-8570w:~$ cat output.txt | grep "Extension Packs" | cut -d: -f 2 | xargs echo
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment