Created
June 1, 2014 14:27
-
-
Save agumonkey/6b0fa8d4b9ea48833381 to your computer and use it in GitHub Desktop.
python sh itemgetter snippet
This file contains 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
import sh | |
from operator import itemgetter | |
ids = [0,3,4,-1] | |
fns = [fn.strip().split(' ') for fn in sh.ls("-lahrtX",_iter=True)][1:] | |
[itemgetter(*ids)(fn) for fn in fns] | |
# [('-rw-r--r--', 'agumonkey', 'agumonkey', 'requirements.hand.txt'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'sql.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'requests.pyquery.over.xml.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'probe-arch-pending.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'nlp.tag.html.bookmarks.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'get-pip.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'fact.py'), | |
# ('-rw-r--r--', 'agumonkey', 'agumonkey', 'setuptools-2.2.tar.gz'), | |
# ('drwxr-xr-x', 'agumonkey', '4.0K', '..'), | |
# ('drwxr-xr-x', 'agumonkey', 'agumonkey', '.'), | |
# ('drwxr-xr-x', 'agumonkey', 'agumonkey', 'venv-old'), | |
# ('drwxr-xr-x', 'agumonkey', 'agumonkey', 'venv')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment